I was trying to validate SAMLResponse assertions using OpenSAML 3. Link: http://shibboleth.net/pipermail/dev/2016-November/008920.html
While i was trying to run the below code, i was getting an exception
java.lang.ClassCastException: org.opensaml.ws.soap.soap11.impl.BodyBuilder cannot be cast to org.opensaml.core.xml.XMLObjectBuilder
This was immediately after executing "InitializationService.initialize()".
@PostConstruct
public void init() {
try {
InitializationService.initialize();
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
docBuilder = documentBuilderFactory.newDocumentBuilder();
unmarshallerFactory =
XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
} catch (Exception e){
logger.error("Error: ",e);
}
}
java.lang.ClassCastException: org.opensaml.ws.soap.soap11.impl.BodyBuilder cannot be cast to org.opensaml.core.xml.XMLObjectBuilder
at org.opensaml.core.xml.config.XMLConfigurator.initializeObjectProviders(XMLConfigurator.java:238)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:203)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:188)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:162)
at org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer.init(AbstractXMLObjectProviderInitializer.java:52)
at org.opensaml.core.config.InitializationService.initialize(InitializationService.java:56)
Below are the dependencies considered in the POM
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-impl</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-soap-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.santuario</groupId>
<artifactId>xmlsec</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.2</version>
</dependency>
Appreciate any pointers on this. Thanks
You'll want to remove the xmltooling dependency from your POM. It is effectively an OpenSAML 2.0 library, and it causes conflicts like the one you're receiving.
For more background detail, see an OpenSAML issue that was filed on this, and a Pac4J issue (which is a Java library that uses OpenSAML).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.