Package org.picketlink.identity.federation.saml.v2.assertion

Examples of org.picketlink.identity.federation.saml.v2.assertion.AttributeStatementType


                AuthnContextTypeSequence sequence = authnContext.getSequence();
                assertNotNull(sequence);
                assertEquals("urn:federation:authentication:windows", sequence.getClassRef().getValue().toString());
            } else if (statement instanceof AttributeStatementType) {
                AttributeStatementType attribStat = (AttributeStatementType) statement;
                List<ASTChoiceType> attributes = attribStat.getAttributes();
                assertEquals(2, attributes.size());
                for (ASTChoiceType astChoice : attributes) {
                    AttributeType attribute = astChoice.getAttribute();
                    String attributeName = attribute.getName();
                    if (!(JBossSAMLURIConstants.CLAIMS_EMAIL_ADDRESS.get().equals(attributeName) || JBossSAMLURIConstants.CLAIMS_PUID
View Full Code Here


    public void testX500Marshalling() throws Exception {
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put(X500SAMLProfileConstants.EMAIL_ADDRESS.getFriendlyName(), "test@a");
        attributes.put(X500SAMLProfileConstants.GIVEN_NAME.getFriendlyName(), "anil");

        AttributeStatementType attrStat = StatementUtil.createAttributeStatement(attributes);

        IssuerInfoHolder issuerHolder = new IssuerInfoHolder("http://idp");
        issuerHolder.setStatusCode(JBossSAMLURIConstants.STATUS_SUCCESS.get());

        IDPInfoHolder idp = new IDPInfoHolder();
View Full Code Here

        attributes.put("TOKEN_USER_ID", String.valueOf(2));
        attributes.put("TOKEN_ORGANIZATION_DISPLAY_NAME", "Test Org");
        attributes.put("TOKEN_USER_DISPLAY_NAME", "Test User");

        AttributeStatementType attributeStatement = StatementUtil.createAttributeStatement(attributes);

        String assertionId = IDGenerator.create("ID_");

        AssertionType assertion = AssertionUtil.createAssertion(assertionId, issuerInfo.getIssuer());
        assertion.addStatement(attributeStatement);
View Full Code Here

        subject.getSubType().addBaseID(nameId);

        assertion.setSubject(subject);
        assertion.addStatement(authnStatement);

        AttributeStatementType attributes = new AttributeStatementType();

        AttributeType attribute = new AttributeType("Role");

        attribute.addAttributeValue("Manager");

        attributes.addAttribute(new ASTChoiceType(attribute));

        assertion.addStatement(attributes);

        id = IDGenerator.create("ID_"); // regenerate
View Full Code Here

        AssertionType assertion = new AssertionType(IDGenerator.create("ID_"), XMLTimeUtil.getIssueInstant());

        Map<String, Object> myattr = new HashMap<String, Object>();
        myattr.put("testKey", "hello");
        AttributeStatementType attState = StatementUtil.createAttributeStatement(myattr);
        assertion.addStatement(attState);

        request.addOption(GeneralConstants.ASSERTION, assertion);
        handler.handleStatusResponseType(request, response);
View Full Code Here

     *
     * @param attributes a map with keys from {@link AttributeConstants}
     * @return
     */
    public static AttributeStatementType createAttributeStatement(Map<String, Object> attributes) {
        AttributeStatementType attrStatement = null;

        int i = 0;

        Set<String> keys = attributes.keySet();
        for (String key : keys) {
            if (i == 0) {
                // Deal with the X500 Profile of SAML2
                attrStatement = new AttributeStatementType();
                i++;
            }

            // if the attribute contains roles, add each role as an attribute.
            if (AttributeConstants.ROLES.equalsIgnoreCase(key)) {
                Object value = attributes.get(key);
                if (value instanceof Collection<?>) {
                    Collection<?> roles = (Collection<?>) value;
                    attrStatement = createAttributeStatement(new ArrayList(roles));
                }
            }

            else {
                AttributeType att;
                Object value = attributes.get(key);

                String uri = X500SAMLProfileConstants.getOID(key);
                if (StringUtil.isNotNull(uri)) {
                    att = getX500Attribute(uri);
                    att.setFriendlyName(key);
                } else {
                    att = new AttributeType(key);
                    att.setFriendlyName(key);
                    att.setNameFormat(JBossSAMLURIConstants.ATTRIBUTE_FORMAT_URI.get());
                }

                att.addAttributeValue(value);
                attrStatement.addAttribute(new ASTChoiceType(att));
            }
        }
        return attrStatement;
    }
View Full Code Here

     *
     * @param roles
     * @return
     */
    public static AttributeStatementType createAttributeStatement(List<String> roles) {
        AttributeStatementType attrStatement = null;
        for (String role : roles) {
            if(attrStatement == null){
                attrStatement = new AttributeStatementType();
            }
            AttributeType attr = new AttributeType(AttributeConstants.ROLE_IDENTIFIER_ASSERTION);
            attr.addAttributeValue(role);
            attrStatement.addAttribute(new ASTChoiceType(attr));
        }
        return attrStatement;
    }
View Full Code Here

     */
    public static AttributeStatementType createAttributeStatementForRoles(List<String> roles, boolean multivalued) {
        if (multivalued == false) {
            return createAttributeStatement(roles);
        }
        AttributeStatementType attrStatement = new AttributeStatementType();
        AttributeType attr = new AttributeType(AttributeConstants.ROLE_IDENTIFIER_ASSERTION);
        for (String role : roles) {
            attr.addAttributeValue(role);
        }
        attrStatement.addAttribute(new ASTChoiceType(attr));
        return attrStatement;
    }
View Full Code Here

     * @param key attribute type
     * @param value attribute value
     * @return
     */
    public static AttributeStatementType createAttributeStatement(String key, String value) {
        AttributeStatementType attrStatement = new AttributeStatementType();
        AttributeType attr = new AttributeType(key);
        attr.addAttributeValue(value);
        attrStatement.addAttribute(new ASTChoiceType(attr));

        return attrStatement;
    }
View Full Code Here

            // Let us get the roles
            Set<StatementAbstractType> statements = assertion.getStatements();
            for (StatementAbstractType statement : statements) {
                if (statement instanceof AttributeStatementType) {
                    AttributeStatementType attributeStatement = (AttributeStatementType) statement;
                    roles.addAll(getRoles(attributeStatement));
                }
            }

            response.setRoles(roles);
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.saml.v2.assertion.AttributeStatementType

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.