Package org.apache.ws.security.saml.ext

Examples of org.apache.ws.security.saml.ext.SAMLCallback


    }
   
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof SAMLCallback) {
                SAMLCallback callback = (SAMLCallback) callbacks[i];

                // Set the Subject
                if (subjectBean != null) {
                    callback.setSubject(subjectBean);
                }
               
                // Set the token Type.
                TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
                String tokenType = tokenRequirements.getTokenType();
                boolean saml1 = false;
                if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType)
                    || WSConstants.SAML2_NS.equals(tokenType)) {
                    callback.setSamlVersion(SAMLVersion.VERSION_20);
                } else {
                    callback.setSamlVersion(SAMLVersion.VERSION_11);
                    saml1 = true;
                    setSubjectOnBeans();
                }
               
                // Set the issuer
                if (issuer == null) {
                    STSPropertiesMBean stsProperties = tokenParameters.getStsProperties();
                    callback.setIssuer(stsProperties.getIssuer());
                } else {
                    callback.setIssuer(issuer);
                }

                // Set the statements
                boolean statementAdded = false;
                if (attributeBeans != null && !attributeBeans.isEmpty()) {
                    callback.setAttributeStatementData(attributeBeans);
                    statementAdded = true;
                }
                if (authBeans != null && !authBeans.isEmpty()) {
                    callback.setAuthenticationStatementData(authBeans);
                    statementAdded = true;
                }
                if (authDecisionBeans != null && !authDecisionBeans.isEmpty()) {
                    callback.setAuthDecisionStatementData(authDecisionBeans);
                    statementAdded = true;
                }
               
                // If SAML 1.1 we *must* add a Statement
                if (saml1 && !statementAdded) {
                    AttributeStatementBean defaultStatement =
                        new DefaultAttributeStatementProvider().getStatement(tokenParameters);
                    defaultStatement.setSubject(subjectBean);
                    callback.setAttributeStatementData(Collections.singletonList(defaultStatement));
                }
               
                // Set the conditions
                callback.setConditions(conditionsBean);
            }
        }
    }
View Full Code Here


    }
   
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof SAMLCallback) {
                SAMLCallback callback = (SAMLCallback) callbacks[i];

                // Set the Subject
                if (subjectBean != null) {
                    callback.setSubject(subjectBean);
                }
               
                // Set the token Type.
                TokenRequirements tokenRequirements = tokenParameters.getTokenRequirements();
                String tokenType = tokenRequirements.getTokenType();
                if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType)
                    || WSConstants.SAML2_NS.equals(tokenType)) {
                    callback.setSamlVersion(SAMLVersion.VERSION_20);
                } else {
                    callback.setSamlVersion(SAMLVersion.VERSION_11);
                    setSubjectOnBeans();
                }
               
                // Set the issuer
                if (issuer == null) {
                    STSPropertiesMBean stsProperties = tokenParameters.getStsProperties();
                    callback.setIssuer(stsProperties.getIssuer());
                } else {
                    callback.setIssuer(issuer);
                }

                // Set the statements
                if (attributeBeans != null && !attributeBeans.isEmpty()) {
                    callback.setAttributeStatementData(attributeBeans);
                }
                if (authBeans != null && !authBeans.isEmpty()) {
                    callback.setAuthenticationStatementData(authBeans);
                }
                if (authDecisionBeans != null && !authDecisionBeans.isEmpty()) {
                    callback.setAuthDecisionStatementData(authDecisionBeans);
                }
               
                // Set the conditions
                callback.setConditions(conditionsBean);
            }
        }
    }
View Full Code Here

   
    public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof SAMLCallback) {
                SAMLCallback callback = (SAMLCallback) callbacks[i];
                callback.setSamlVersion(SAMLVersion.VERSION_20);
                callback.setIssuer(issuer);
                if (conditions != null) {
                    callback.setConditions(conditions);
                }
               
                SubjectBean subjectBean =
                    new SubjectBean(
                        subjectName, subjectQualifier, confirmationMethod
                    );
                if (subjectNameIDFormat != null) {
                    subjectBean.setSubjectNameIDFormat(subjectNameIDFormat);
                }
                subjectBean.setSubjectConfirmationData(subjectConfirmationData);
                if (SAML2Constants.CONF_HOLDER_KEY.equals(confirmationMethod)) {
                    try {
                        KeyInfoBean keyInfo = createKeyInfo();
                        subjectBean.setKeyInfo(keyInfo);
                    } catch (Exception ex) {
                        throw new IOException("Problem creating KeyInfo: " +  ex.getMessage());
                    }
                }
                callback.setSubject(subjectBean);
                createAndSetStatement(null, callback);
            } else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.ws.security.saml.ext.SAMLCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.