使用opensaml库

时间:2016-05-19 15:06:00

标签: authentication saml saml-2.0 wso2is opensaml

我正在学习SAML实现,我经历了spring-security saml示例,目前正在生成的AuthRequest默认发生,我正在尝试自定义我的authRequest。

我一直在浏览opensaml库并且正在尝试实现 WebSSOProfilesImpl 类,其中在 getAuthnRequest()中我实现了以下代码。

protected AuthnRequest getAuthnRequest(SAMLMessageContext context, WebSSOProfileOptions options,
                                       AssertionConsumerService assertionConsumer,
                                       SingleSignOnService bindingService) throws SAMLException, MetadataProviderException {

    SAMLObjectBuilder<AuthnRequest> builder = 
            (SAMLObjectBuilder<AuthnRequest>) builderFactory.getBuilder
            (new QName("urn:oasis:names:tc:xacml:3.0:profile:saml2.0:v2:schema:protocol:wd-13", "XACMLAuthzDecisionQueryType",
                "xacml-samlp"));
    System.out.println("Builder : "+builder.toString()+" "+builder);
    AuthnRequest request = builder.buildObject();
    System.out.println("request : "+request.toString());
    request.setIsPassive(options.getPassive());
    request.setForceAuthn(options.getForceAuthN());
    request.setProviderName(options.getProviderName());
    request.setVersion(SAMLVersion.VERSION_20);

    buildCommonAttributes(context.getLocalEntityId(), request, bindingService);

    buildScoping(request, bindingService, options);
    builNameIDPolicy(request, options);
    buildAuthnContext(request, options);
    buildReturnAddress(request, assertionConsumer);

    return request;

}

但是当我使用IDP登录到我的IS时,我在 SAMLObjectBuilder 对象中得到NullPointerException。我做错了什么?请帮忙,任何帮助都非常感谢!!!

注意: 我在QName中传递的值是我想要给出的值,我可以遵循XACML-SAML决策查询用例。