Search in sources :

Example 1 with SubjectProviderParameters

use of org.apache.cxf.sts.token.provider.SubjectProviderParameters in project cxf by apache.

the class SCTSAMLTokenProvider method createCallbackHandler.

public SamlCallbackHandler createCallbackHandler(TokenProviderParameters tokenParameters, byte[] secret, Document doc) throws Exception {
    // Parse the AttributeStatements
    List<AttributeStatementBean> attrBeanList = null;
    if (attributeStatementProviders != null && !attributeStatementProviders.isEmpty()) {
        attrBeanList = new ArrayList<>();
        for (AttributeStatementProvider statementProvider : attributeStatementProviders) {
            AttributeStatementBean statementBean = statementProvider.getStatement(tokenParameters);
            if (statementBean != null) {
                LOG.fine("AttributeStatements" + statementBean.toString() + "returned by AttributeStatementProvider " + statementProvider.getClass().getName());
                attrBeanList.add(statementBean);
            }
        }
    }
    // If no statements, then default to the DefaultAttributeStatementProvider
    if (attrBeanList == null || attrBeanList.isEmpty()) {
        attrBeanList = new ArrayList<>();
        AttributeStatementProvider attributeProvider = new DefaultAttributeStatementProvider();
        AttributeStatementBean attributeBean = attributeProvider.getStatement(tokenParameters);
        attrBeanList.add(attributeBean);
    }
    // Get the Subject and Conditions
    SubjectProviderParameters subjectProviderParameters = new SubjectProviderParameters();
    subjectProviderParameters.setProviderParameters(tokenParameters);
    subjectProviderParameters.setDoc(doc);
    subjectProviderParameters.setSecret(secret);
    subjectProviderParameters.setAttrBeanList(attrBeanList);
    SubjectBean subjectBean = subjectProvider.getSubject(subjectProviderParameters);
    ConditionsBean conditionsBean = conditionsProvider.getConditions(tokenParameters);
    // Set all of the beans on the SamlCallbackHandler
    SamlCallbackHandler handler = new SamlCallbackHandler();
    handler.setTokenProviderParameters(tokenParameters);
    handler.setSubjectBean(subjectBean);
    handler.setConditionsBean(conditionsBean);
    handler.setAttributeBeans(attrBeanList);
    return handler;
}
Also used : SubjectBean(org.apache.wss4j.common.saml.bean.SubjectBean) SamlCallbackHandler(org.apache.cxf.sts.token.provider.SamlCallbackHandler) AttributeStatementBean(org.apache.wss4j.common.saml.bean.AttributeStatementBean) ConditionsBean(org.apache.wss4j.common.saml.bean.ConditionsBean) DefaultAttributeStatementProvider(org.apache.cxf.sts.token.provider.DefaultAttributeStatementProvider) AttributeStatementProvider(org.apache.cxf.sts.token.provider.AttributeStatementProvider) DefaultAttributeStatementProvider(org.apache.cxf.sts.token.provider.DefaultAttributeStatementProvider) SubjectProviderParameters(org.apache.cxf.sts.token.provider.SubjectProviderParameters)

Aggregations

AttributeStatementProvider (org.apache.cxf.sts.token.provider.AttributeStatementProvider)1 DefaultAttributeStatementProvider (org.apache.cxf.sts.token.provider.DefaultAttributeStatementProvider)1 SamlCallbackHandler (org.apache.cxf.sts.token.provider.SamlCallbackHandler)1 SubjectProviderParameters (org.apache.cxf.sts.token.provider.SubjectProviderParameters)1 AttributeStatementBean (org.apache.wss4j.common.saml.bean.AttributeStatementBean)1 ConditionsBean (org.apache.wss4j.common.saml.bean.ConditionsBean)1 SubjectBean (org.apache.wss4j.common.saml.bean.SubjectBean)1