我是一名大学生,试图在 Java 中为 WebSSO 实现一个服务提供商插件。我使用 Shibboleth IdP 作为身份提供者。我已经能够将身份验证请求发送到 IdP,并通过 servlet 成功接收到来自 IdP 的响应。我尝试解码响应并获得 XMLObject。现在的问题是响应已加密。所以当我使用
Assertion assertion = response.getAssertions().get(0);
它基本上返回空值。但是当我使用
Assertion assertion = response.getEncryptedAssertions().get(0);
不为空。所以这基本上意味着响应是加密的。现在我不知道如何解密 SAMLReponse 的流程。欢迎任何指针、代码或建议。
最佳答案
您可以使用这样的东西(将 yourCredential
替换为您的 Credential
对象):
StaticKeyInfoCredentialResolver keyresolver =
new StaticKeyInfoCredentialResolver(yourCredential);
Decrypter samlDecrypter = new Decrypter(null, keyresolver, new InlineEncryptedKeyResolver());
Assertion assertion = samlDecrypter.decrypt(response.getEncryptedAssertions().get(0));
如果您的场景更复杂,可以在 shibboleth 的 wiki 上找到更详细的示例:Link
关于java - 如何解密从 Shibboleth IdP 收到的 SAMLResponse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21875066/