[java-opensaml COMMIT] in /trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec: encryption/support/Decrypter....
noreply at shibboleth.net
noreply at shibboleth.net
Mon Jan 14 21:39:30 EST 2013
Author: scantor
Date: Mon Jan 14 21:39:30 2013
New Revision: 3145
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3145&view=rev
Log:
Check for null builders, and fail to default unmarshaller during decryption.
Modified:
trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Decrypter.java
trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Encrypter.java
trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/keyinfo/KeyInfoSupport.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=3145&r1=3144&r2=3145&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 Mon Jan 14 21:39:30 2013
@@ -36,6 +36,7 @@
import net.shibboleth.utilities.java.support.resolver.Criterion;
import net.shibboleth.utilities.java.support.resolver.ResolverException;
import net.shibboleth.utilities.java.support.xml.BasicParserPool;
+import net.shibboleth.utilities.java.support.xml.QNameSupport;
import net.shibboleth.utilities.java.support.xml.XMLParserException;
import org.apache.xml.security.Init;
@@ -45,6 +46,7 @@
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.Marshaller;
import org.opensaml.core.xml.io.MarshallingException;
+import org.opensaml.core.xml.io.Unmarshaller;
import org.opensaml.core.xml.io.UnmarshallerFactory;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.security.credential.Credential;
@@ -487,7 +489,20 @@
}
try {
- xmlObject = unmarshallerFactory.getUnmarshaller(element).unmarshall(element);
+ Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
+ if (unmarshaller == null) {
+ unmarshaller = unmarshallerFactory.getUnmarshaller(
+ XMLObjectProviderRegistrySupport.getDefaultProviderQName());
+ if (unmarshaller == null) {
+ String errorMsg = "No unmarshaller available for " + QNameSupport.getNodeQName(element);
+ log.error(errorMsg);
+ throw new UnmarshallingException(errorMsg);
+ } else {
+ log.debug("No unmarshaller was registered for {}. Using default unmarshaller.",
+ QNameSupport.getNodeQName(element));
+ }
+ }
+ xmlObject = unmarshaller.unmarshall(element);
} catch (UnmarshallingException e) {
log.error("There was an error during unmarshalling of the decrypted element", e);
throw new DecryptionException("Unmarshalling error during decryption", e);
Modified: trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Encrypter.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Encrypter.java?rev=3145&r1=3144&r2=3145&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Encrypter.java (original)
+++ trunk/opensaml-xmlsec-api/src/main/java/org/opensaml/xmlsec/encryption/support/Encrypter.java Mon Jan 14 21:39:30 2013
@@ -118,9 +118,12 @@
UnmarshallerFactory unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
encryptedDataUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedData.DEFAULT_ELEMENT_NAME);
encryptedKeyUnmarshaller = unmarshallerFactory.getUnmarshaller(EncryptedKey.DEFAULT_ELEMENT_NAME);
+ Constraint.isNotNull(encryptedDataUnmarshaller, "EncryptedData unmarshaller not configured");
+ Constraint.isNotNull(encryptedKeyUnmarshaller, "EncryptedKey unmarshaller not configured");
XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
keyInfoBuilder = (XMLSignatureBuilder<KeyInfo>) builderFactory.getBuilder(KeyInfo.DEFAULT_ELEMENT_NAME);
+ Constraint.isNotNull(keyInfoBuilder, "KeyInfo builder not configured");
}
/**
@@ -537,8 +540,12 @@
protected void checkAndMarshall(@Nonnull final XMLObject xmlObject) throws EncryptionException {
Element targetElement = xmlObject.getDOM();
if (targetElement == null) {
- Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(xmlObject);
try {
+ Marshaller marshaller =
[... 227 lines stripped ...]
More information about the commits
mailing list