简体   繁体   中英

Opensaml error receiving correct unmarshaller

I am running this code at opensaml2.6

Element metadataRoot = document.getDocumentElement();

// Unmarshall
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);
if (unmarshaller == null) {
    System.out.println("Error receiving unmarshaller for this document.");
    return;
}

For the document

<?xml version="1.0" encoding="UTF-8"?><saml2:EncryptedAssertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">

Unmarshaller return a null , Can you help me to undertand how are the criterias to lookup the correct Unmarshaller and how this works at opensaml?

I found that there is not unmarshallers register as there is not initialization in the library:

Important piece of code:

// Initialize the library
DefaultBootstrap.bootstrap();

In OpenSAML3 you have to first make sure to include the opensaml-saml-impl artifact in your dependencies, since all the marshallers and unmarshallers are implemented there.

Then, as @Goblins and @Pegerto pointed out, you have to call InitializationService.initialize() . I have found this link to be useful for doing a correct initialization when using Dependency Injection https://github.com/apereo/cas/blob/master/support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/OpenSamlConfigBean.java

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM