public AttributeStatementType getAttributeStatement() { Subject subject = SecurityActions.getSecurityContext().getSubjectInfo().getAuthenticatedSubject(); if (subject == null) { logger.trace("No authentication Subject found, cannot provide any user roles!"); return null; } else { AttributeStatementType attributeStatement = new AttributeStatementType(); AttributeType rolesAttribute = new AttributeType(tokenRoleAttributeName); attributeStatement.addAttribute(new ASTChoiceType(rolesAttribute)); // List<Object> roles = rolesAttribute.getAttributeValue(); for (Principal rolePrincipal : subject.getPrincipals()) { if (JBOSS_ROLE_PRINCIPAL_NAME.equalsIgnoreCase(rolePrincipal.getName())) { Group simpleGroup = (Group) rolePrincipal; Enumeration<? extends Principal> members = simpleGroup.members(); while (members.hasMoreElements()) { Principal role = members.nextElement(); rolesAttribute.addAttributeValue(role.getName()); // roles.add( role.getName() ); } } } logger .trace("Returning an AttributeStatement with a [" + tokenRoleAttributeName + "] attribute containing: " + rolesAttribute .getAttributeValue().toString()); return attributeStatement; } } }
/** * Given a set of roles, create an attribute statement * * @param roles * @param multivalued if you want the attribute to be multi valued * * @return */ 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; }
/** * Given a set of roles, create an attribute statement * * @param roles * @param multivalued if you want the attribute to be multi valued * @return */ 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; }
/** * Add the user's current roles as attribute statement(s) on the SAML Assertion. * @param roles * @param assertion * @param principal */ private static void addRoleStatements(Set<String> roles, AssertionType assertion, Principal principal) { AttributeType attribute = new AttributeType("Role"); //$NON-NLS-1$ ASTChoiceType attributeAST = new ASTChoiceType(attribute); AttributeStatementType roleStatement = new AttributeStatementType(); roleStatement.addAttribute(attributeAST); if (roles != null) { for (String role : roles) { attribute.addAttributeValue(role); } } assertion.addStatement(roleStatement); }
/** * Given a set of roles, create an attribute statement * * @param roles * @param multivalued if you want the attribute to be multi valued * * @return */ 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; }
/** * Given a set of roles, create an attribute statement * * @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; }
/** * Given a set of roles, create an attribute statement * * @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; }
/** * Given a set of roles, create an attribute statement * * @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; }
/** * Given a set of roles, create an attribute statement * @param roles * @return */ public static AttributeStatementType createAttributeStatement(List<String> roles) { AttributeStatementType attrStatement = new AttributeStatementType(); for (String role : roles) { AttributeType attr = new AttributeType("Role"); attr.addAttributeValue(role); attrStatement.addAttribute(new ASTChoiceType(attr)); } return attrStatement; }
/** * Given a set of roles, create an attribute statement * @param roles * @return */ public static AttributeStatementType createAttributeStatement(List<String> roles) { AttributeStatementType attrStatement = new AttributeStatementType(); for (String role : roles) { AttributeType attr = new AttributeType("Role"); attr.addAttributeValue(role); attrStatement.addAttribute(new ASTChoiceType(attr)); } return attrStatement; }
/** * Given an attribute type and a value, create {@link AttributeStatementType} * * @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; }
/** * Given an attribute type and a value, create {@link AttributeStatementType} * @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; }
/** * Given an attribute type and a value, create {@link AttributeStatementType} * * @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; }
/** * Given an attribute type and a value, create {@link AttributeStatementType} * * @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; }
/** * Create an AttributeStatement given an attribute * @param attributeValue * @return */ public static AttributeStatementType createAttributeStatement(String attributeValue) { AttributeStatementType attribStatement = new AttributeStatementType(); AttributeType att = new AttributeType( attributeValue ); att.addAttributeValue(attributeValue); attribStatement.addAttribute( new ASTChoiceType( att )); return attribStatement; }
/** * Create an AttributeStatement given an attribute * * @param attributeValue * @return */ public static AttributeStatementType createAttributeStatement(String attributeValue) { AttributeStatementType attribStatement = new AttributeStatementType(); AttributeType att = new AttributeType(attributeValue); att.addAttributeValue(attributeValue); attribStatement.addAttribute(new ASTChoiceType(att)); return attribStatement; }
/** * Create an AttributeStatement given an attribute * * @param attributeValue * * @return */ public static AttributeStatementType createAttributeStatement(String attributeValue) { AttributeStatementType attribStatement = new AttributeStatementType(); AttributeType att = new AttributeType(attributeValue); att.addAttributeValue(attributeValue); attribStatement.addAttribute(new ASTChoiceType(att)); return attribStatement; }
/** * Create an AttributeStatement given an attribute * * @param attributeValue * * @return */ public static AttributeStatementType createAttributeStatement(String attributeValue) { AttributeStatementType attribStatement = new AttributeStatementType(); AttributeType att = new AttributeType(attributeValue); att.addAttributeValue(attributeValue); attribStatement.addAttribute(new ASTChoiceType(att)); return attribStatement; }
/** * Create an AttributeStatement given an attribute * @param attributeValue * @return */ public static AttributeStatementType createAttributeStatement(String attributeValue) { AttributeStatementType attribStatement = new AttributeStatementType(); AttributeType att = new AttributeType( attributeValue ); att.addAttributeValue(attributeValue); attribStatement.addAttribute( new ASTChoiceType( att )); return attribStatement; }
/** * Given an attribute type and a value, create {@link AttributeStatementType} * @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; }