[英]Prepare SAML Authentication request using OpenSaml3.1.1
我们正在使用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生成器=新的SecureRandomIdentifierGenerator(); 的sessionId = generator.generateIdentifier();
A.2)使用Open SAML 3.1.1
B)如何使用开放SAML 3.1.1发送SAML请求B.1)使用开放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生成器=新的SecureRandomIdentifierGenerator(); 的sessionId = generator.generateIdentifier();
A.2)使用Open SAML 3.1.1
v3版本是位于java-support中的net.shibboleth.utilities.java.support.security.SecureRandomIdentifierGenerationStrategy。
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上使用更高级别的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.