[英]Opensaml error receiving correct unmarshaller
I am running this code at opensaml2.6我在 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? Unmarshaller
返回一个null
,你能帮我理解如何查找正确的Unmarshaller
的标准以及它在 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.在 OpenSAML3 中,您必须首先确保在您的依赖项中包含opensaml-saml-impl
工件,因为所有编组器和解组器都在那里实现。
Then, as @Goblins and @Pegerto pointed out, you have to call InitializationService.initialize()
.然后,正如@Goblins 和@Pegerto 指出的那样,您必须调用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我发现此链接对于在使用依赖注入时进行正确的初始化很有用https://github.com/apereo/cas/blob/master/support/cas-server-support-saml-core-api/src/main /java/org/apereo/cas/support/saml/OpenSamlConfigBean.java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.