Search in sources :

Example 1 with SubjectLocalityBean

use of org.apache.wss4j.common.saml.bean.SubjectLocalityBean in project cxf by apache.

the class AbstractSAMLCallbackHandler method createAndSetStatement.

/**
 * Note that the SubjectBean parameter should be null for SAML2.0
 */
protected void createAndSetStatement(SubjectBean subjectBean, SAMLCallback callback) {
    if (statement == Statement.AUTHN) {
        AuthenticationStatementBean authBean = new AuthenticationStatementBean();
        if (subjectBean != null) {
            authBean.setSubject(subjectBean);
        }
        if (subjectLocalityIpAddress != null || subjectLocalityDnsAddress != null) {
            SubjectLocalityBean subjectLocality = new SubjectLocalityBean();
            subjectLocality.setIpAddress(subjectLocalityIpAddress);
            subjectLocality.setDnsAddress(subjectLocalityDnsAddress);
            authBean.setSubjectLocality(subjectLocality);
        }
        authBean.setAuthenticationInstant(authnInstant);
        authBean.setSessionNotOnOrAfter(sessionNotOnOrAfter);
        authBean.setAuthenticationMethod("Password");
        callback.setAuthenticationStatementData(Collections.singletonList(authBean));
    } else if (statement == Statement.ATTR) {
        AttributeStatementBean attrBean = new AttributeStatementBean();
        AttributeBean attributeBean = new AttributeBean();
        if (subjectBean != null) {
            attrBean.setSubject(subjectBean);
            attributeBean.setSimpleName("role");
            attributeBean.setQualifiedName("http://custom-ns");
        } else {
            attributeBean.setQualifiedName("role");
        }
        if (customAttributeValues != null) {
            attributeBean.setAttributeValues(customAttributeValues);
        } else {
            attributeBean.addAttributeValue("user");
        }
        attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
        callback.setAttributeStatementData(Collections.singletonList(attrBean));
    } else {
        AuthDecisionStatementBean authzBean = new AuthDecisionStatementBean();
        if (subjectBean != null) {
            authzBean.setSubject(subjectBean);
        }
        ActionBean actionBean = new ActionBean();
        actionBean.setContents("Read");
        authzBean.setActions(Collections.singletonList(actionBean));
        authzBean.setResource("endpoint");
        authzBean.setDecision(AuthDecisionStatementBean.Decision.PERMIT);
        authzBean.setResource(resource);
        callback.setAuthDecisionStatementData(Collections.singletonList(authzBean));
    }
}
Also used : SubjectLocalityBean(org.apache.wss4j.common.saml.bean.SubjectLocalityBean) AttributeStatementBean(org.apache.wss4j.common.saml.bean.AttributeStatementBean) AuthenticationStatementBean(org.apache.wss4j.common.saml.bean.AuthenticationStatementBean) AuthDecisionStatementBean(org.apache.wss4j.common.saml.bean.AuthDecisionStatementBean) AttributeBean(org.apache.wss4j.common.saml.bean.AttributeBean) ActionBean(org.apache.wss4j.common.saml.bean.ActionBean)

Example 2 with SubjectLocalityBean

use of org.apache.wss4j.common.saml.bean.SubjectLocalityBean in project cxf by apache.

the class CustomAuthenticationProvider method getStatement.

/**
 * Get an AuthenticationStatementBean using the given parameters.
 */
public AuthenticationStatementBean getStatement(TokenProviderParameters providerParameters) {
    AuthenticationStatementBean authBean = new AuthenticationStatementBean();
    SubjectLocalityBean subjectLocality = new SubjectLocalityBean();
    subjectLocality.setIpAddress("127.0.0.1");
    authBean.setSubjectLocality(subjectLocality);
    if (WSS4JConstants.WSS_SAML_TOKEN_TYPE.equals(providerParameters.getTokenRequirements().getTokenType())) {
        authBean.setAuthenticationMethod(SAML1Constants.AUTH_METHOD_X509);
    } else {
        authBean.setAuthenticationMethod(SAML2Constants.AUTH_CONTEXT_CLASS_REF_X509);
    }
    return authBean;
}
Also used : SubjectLocalityBean(org.apache.wss4j.common.saml.bean.SubjectLocalityBean) AuthenticationStatementBean(org.apache.wss4j.common.saml.bean.AuthenticationStatementBean)

Aggregations

AuthenticationStatementBean (org.apache.wss4j.common.saml.bean.AuthenticationStatementBean)2 SubjectLocalityBean (org.apache.wss4j.common.saml.bean.SubjectLocalityBean)2 ActionBean (org.apache.wss4j.common.saml.bean.ActionBean)1 AttributeBean (org.apache.wss4j.common.saml.bean.AttributeBean)1 AttributeStatementBean (org.apache.wss4j.common.saml.bean.AttributeStatementBean)1 AuthDecisionStatementBean (org.apache.wss4j.common.saml.bean.AuthDecisionStatementBean)1