[java-opensaml COMMIT] /trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java
noreply at shibboleth.net
noreply at shibboleth.net
Thu Jun 6 01:15:51 EDT 2013
Author: putmanb
Date: Thu Jun 6 01:15:51 2013
New Revision: 3367
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3367&view=rev
Log:
OSJ-50: Decrypter should be defensive about Santuario and Java crypto classes throwing unchecked exceptions .
Modified:
trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java
Modified: trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java?rev=3367&r1=3366&r2=3367&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java (original)
+++ trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java Thu Jun 6 01:15:51 2013
@@ -612,6 +612,11 @@
} catch (XMLEncryptionException e) {
log.error("Error decrypting the encrypted data element", e);
throw new DecryptionException("Error decrypting the encrypted data element", e);
+ } catch (Exception e) {
+ // Catch anything else, esp. unchecked RuntimeException, and convert to our checked type.
+ // BouncyCastle in particular is known to throw unchecked exceptions for what we would
+ // consider "routine" failures.
+ throw new DecryptionException("Probable runtime exception on decryption:" + e.getMessage(), e);
}
if (bytes == null) {
throw new DecryptionException("EncryptedData could not be decrypted");
@@ -708,7 +713,7 @@
} catch (XMLEncryptionException e) {
log.error("Error when loading library native encrypted key representation", e);
throw new DecryptionException("Error when loading library native encrypted key representation", e);
- }
+ }
try {
Key key = xmlCipher.decryptKey(encKey, algorithm);
@@ -719,6 +724,11 @@
} catch (XMLEncryptionException e) {
log.error("Error decrypting encrypted key", e);
throw new DecryptionException("Error decrypting encrypted key", e);
+ } catch (Exception e) {
+ // Catch anything else, esp. unchecked RuntimeException, and convert to our checked type.
+ // BouncyCastle in particular is known to throw unchecked exceptions for what we would
+ // consider "routine" failures.
+ throw new DecryptionException("Probable runtime exception on decryption:" + e.getMessage(), e);
}
}
More information about the commits
mailing list