如何在 Spring SAML 中显示断言的原始内容 (DOM)?

How to display original content (DOM) of the assertion in Spring SAML?

对于我的项目,我需要向用户显示 SAML 响应的加密和解密版本。

目前 Spring SAML 示例应用程序显示加密的(即原始的)SAML 响应,但我不确定如何显示所有元素(NameID、断言和其他元素)已解密的相同响应。

我知道 Spring SAML 示例应用程序以 table 格式显示断言,但我需要显示整个 'decrypted' XML SAML 响应所有标签和属性。

注意我正在处理 SP 部分,IDP 配置为发送带有加密属性和 NameID 的加密 SAML 响应。

感谢任何帮助。

Part 9.5 of the manual 应该能帮到你。

9.5 Authentication assertion

Assertion used to authenticate user is stored in the SAMLCredential object under property authenticationAssertion. By default the original content (DOM) of the assertion is discarded and system only keeps an unmarshalled version which might slightly differ from the original, e.g. in white-spaces. In order to instruct Spring SAML to keep the assertion in the original form (keep its DOM) set property releaseDOM to false on bean WebSSOProfileConsumerImpl.

Assertion can be serialized to String using the following call:

XMLHelper.nodeToString(SAMLUtil.marshallMessage(credential.getAuthenticationAssertion()))