【发布时间】:2015-09-12 16:18:58
【问题描述】:
使用 spring-security-saml 处理来自 IDP 的断言,在服务器启动 1 到 2 小时后低于错误。问题并非一直都可重现。通过查看堆栈跟踪,问题似乎与 spring saml 配置中使用的解析器池有关。请分享任何想法。
库版本: opensaml 2.6.1 spring-security-saml2 1.0.0.RELEASE
解析器池配置:
<bean id="parserPool" class="org.opensaml.xml.parse.StaticBasicParserPool" init-method="initialize">
<property name="builderFeatures">
<map>
<entry key="http://apache.org/xml/features/dom/defer-node-expansion" value="false"/>
</map>
</property>
</bean>
<bean id="parserPoolHolder" class="org.springframework.security.saml.parser.ParserPoolHolder"/>
堆栈跟踪是:
org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
at org.apache.xerces.dom.ParentNode.internalInsertBefore(Unknown Source)
at org.apache.xerces.dom.ParentNode.insertBefore(Unknown Source)
at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
at org.opensaml.xml.encryption.Decrypter.parseInputStream(Decrypter.java:821)
at org.opensaml.xml.encryption.Decrypter.decryptDataToDOM(Decrypter.java:599)
at org.opensaml.xml.encryption.Decrypter.decryptUsingResolvedEncryptedKey(Decrypter.java:784)
at org.opensaml.xml.encryption.Decrypter.decryptDataToDOM(Decrypter.java:524)
at org.opensaml.xml.encryption.Decrypter.decryptDataToList(Decrypter.java:442)
at org.opensaml.xml.encryption.Decrypter.decryptData(Decrypter.java:403)
at org.opensaml.saml2.encryption.Decrypter.decryptData(Decrypter.java:141)
at org.opensaml.saml2.encryption.Decrypter.decrypt(Decrypter.java:69)
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:199)
at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82)
【问题讨论】:
-
检查下面的链接是否有帮助stackoverflow.com/questions/30341590/…
-
发现问题。我的项目也有用于 word 文档处理的 docx4j,docx4j 在初始化时更改了系统属性 javax.xml.parsers.DocumentBuilderFactory,这在内部导致返回一个 DocumentBuilderFactory 实现,该实现与初始化 opensaml 时使用的不同。
标签: spring-saml opensaml