gpt4 book ai didi

java - 使用 OpenSaml3.1.1 准备 SAML 身份验证请求

转载 作者:行者123 更新时间:2023-11-30 08:08:34 26 4
gpt4 key购买 nike

我们正在使用 shibboleth-idp 使用 shibboleth 的 SSO 解决方案对用户进行身份验证。我们能够进行 idp 升级(2.4 到 3.1.1),并且我们还能够检查 IdP 3.1.1 的状态。( http://localhost:8080/idp/profile/status )

据我们所知,“IdP 2.4”使用 OpenSaml2.6,IdP 3.1.1 使用 Opensaml 3.1.1,

我们有以下有关 OpenSAML 3.1.1 的查询

A) OpenSAML 3.1.1 中用于“SecureRandomIdentifierGenerator”的替代 API

A.1) 下面给出了在 SP(非 shibboleth SP 组件)中使用 Open SAML 2.6 示例 SessionID 生成::

SecureRandomIdentifierGenerator 生成器 = new SecureRandomIdentifierGenerator(); sessionId=generator.generateIdentifier();

A.2) 使用开放 SAML 3.1.1 ???

B) 如何使用 Open SAML 3.1.1 发送 SAML 请求 B.1) 使用 Open SAML 2.6 从 SP(非 shibboleth SP 组件)到 Idp 2.4(Shibboleth 组件)的示例 SAML 请求如下: 我们调用“getAuthnRequest()”方法来生成 SAML 请求(我们使用的是 SAML 2.6)

            private AuthnRequest getAuthnRequest(DateTime issueInstant, Issuer issuer,
String consumerUrl, String spUrl) {

AuthnRequestBuilder authRequestBuilder = new AuthnRequestBuilder();
AuthnRequest authRequest = authRequestBuilder
.buildObject("urn:oasis:names:tc:SAML:2.0:protocol",
"AuthnRequest", "samlp");
authRequest.setForceAuthn(new Boolean(false));
authRequest.setIsPassive(new Boolean(false));
authRequest.setIssueInstant(issueInstant);
authRequest
.setProtocolBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST");
authRequest.setAssertionConsumerServiceURL(consumerUrl);
authRequest.setIssuer(issuer);
authRequest.setAttributeConsumingServiceIndex(1);

return authRequest;

}

B.2) 使用开放 SAML 3.1.1 ???

请建议我们使用opensaml 3.1.1来准备saml authn请求。

最佳答案

这是我从官方论坛得到的回复:

A) OpenSAML 3.1.1 中用于“SecureRandomIdentifierGenerator”的替代 API

A.1) 下面给出了在 SP(非 shibboleth SP 组件)中使用 Open SAML 2.6 示例 SessionID 生成::

SecureRandomIdentifierGenerator 生成器 = new SecureRandomIdentifierGenerator(); sessionId=generator.generateIdentifier();

A.2) 使用开放 SAML 3.1.1 ???

v3版本是net.shibboleth.utilities.java.support.security.SecureRandomIdentifierGenerationStrategy位于 java-support 中。

B) 如何使用 Open SAML 3.1.1 发送 SAML 请求

            private AuthnRequest getAuthnRequest(DateTime issueInstant, Issuer issuer,
String consumerUrl, String spUrl) {

AuthnRequestBuilder authRequestBuilder = new AuthnRequestBuilder();

B.2) 使用开放 SAML 3.1.1 ???

包名称已更改,现在位于 org.opensaml.saml.saml2.core.impl.AuthnRequestBuilder 中。但除此之外我相信应该是完全相同的。您没有使用 Eclipse 或其他 IDE 吗?它可以帮助进行简单的包导入更改。

顺便说一句,在 v2 和 v3 中,我们不鼓励直接使用这样的 -Builder 类。我们建议您通过注册的提供程序获取 XMLObject 构建器、编码器和解码器。在 v2 中,构建器用法:

https://wiki.shibboleth.net/confluence/display/OpenSAML/OSTwoUsrManJavaCreateFromScratch

在 v3 中,还没有 wiki 文档,但可以通过 org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport 使用全局 XMLObjectProviderRegistry,或者使用 org.opensaml.core.xml.util.XMLObjectSupport 上的更高级别方法。

关于java - 使用 OpenSaml3.1.1 准备 SAML 身份验证请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30730772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com