From 8c6813ce565567ed84d5b1e0a5ee32a14634a984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Barab=C3=A1s?= Date: Tue, 5 Apr 2022 10:38:19 +0200 Subject: [PATCH] #266 Handle ClassCastException in signature.init calls --- .../signature/consumer/SignatureValidator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/signature/consumer/SignatureValidator.java b/pgpainless-core/src/main/java/org/pgpainless/signature/consumer/SignatureValidator.java index 3572fff0..51bfa7c3 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/signature/consumer/SignatureValidator.java +++ b/pgpainless-core/src/main/java/org/pgpainless/signature/consumer/SignatureValidator.java @@ -461,7 +461,7 @@ public abstract class SignatureValidator { if (!valid) { throw new SignatureValidationException("Signature is not correct."); } - } catch (PGPException e) { + } catch (PGPException | ClassCastException e) { throw new SignatureValidationException("Cannot verify subkey binding signature correctness", e); } } @@ -485,7 +485,7 @@ public abstract class SignatureValidator { if (!valid) { throw new SignatureValidationException("Primary Key Binding Signature is not correct."); } - } catch (PGPException e) { + } catch (PGPException | ClassCastException e) { throw new SignatureValidationException("Cannot verify primary key binding signature correctness", e); } } @@ -514,7 +514,7 @@ public abstract class SignatureValidator { if (!valid) { throw new SignatureValidationException("Signature is not correct."); } - } catch (PGPException e) { + } catch (PGPException | ClassCastException e) { throw new SignatureValidationException("Cannot verify direct-key signature correctness", e); } } @@ -577,7 +577,7 @@ public abstract class SignatureValidator { if (!valid) { throw new SignatureValidationException("Signature over user-id '" + userId + "' is not correct."); } - } catch (PGPException e) { + } catch (PGPException | ClassCastException e) { throw new SignatureValidationException("Cannot verify signature over user-id '" + userId + "'.", e); } } @@ -602,7 +602,7 @@ public abstract class SignatureValidator { if (!valid) { throw new SignatureValidationException("Signature over user-attribute vector is not correct."); } - } catch (PGPException e) { + } catch (PGPException | ClassCastException e) { throw new SignatureValidationException("Cannot verify signature over user-attribute vector.", e); } }