public static Map<String, Object> asMap(Set<AttributeStatementType> attributeStatementTypes) { Map<String, Object> attrMap = new HashMap<String, Object>(); if (attributeStatementTypes != null && !attributeStatementTypes.isEmpty()) { attrMap = new HashMap<String, Object>(); for (StatementAbstractType statement : attributeStatementTypes) { if (statement instanceof AttributeStatementType) { AttributeStatementType attrStat = (AttributeStatementType) statement; List<ASTChoiceType> attrs = attrStat.getAttributes(); for (ASTChoiceType attrChoice : attrs) { AttributeType attr = attrChoice.getAttribute(); String attributeName = attr.getFriendlyName(); if (attributeName == null) { attributeName = attr.getName(); } List<Object> values = attr.getAttributeValue(); if (values != null) { if (values.size() == 1) { attrMap.put(attributeName, values.get(0)); } else { attrMap.put(attributeName, values); } } } } } } return attrMap; }
public static Map<String, Object> asMap(Set<AttributeStatementType> attributeStatementTypes) { Map<String, Object> attrMap = new HashMap<String, Object>(); if (attributeStatementTypes != null && !attributeStatementTypes.isEmpty()) { attrMap = new HashMap<String, Object>(); for (StatementAbstractType statement : attributeStatementTypes) { if (statement instanceof AttributeStatementType) { AttributeStatementType attrStat = (AttributeStatementType) statement; List<ASTChoiceType> attrs = attrStat.getAttributes(); for (ASTChoiceType attrChoice : attrs) { AttributeType attr = attrChoice.getAttribute(); String attributeName = attr.getFriendlyName(); if (attributeName == null) { attributeName = attr.getName(); } List<Object> values = attr.getAttributeValue(); if (values != null) { if (values.size() == 1) { attrMap.put(attributeName, values.get(0)); } else { attrMap.put(attributeName, values); } } } } } } return attrMap; }
continue; List<Object> attributeValues = attr.getAttributeValue(); if (attributeValues != null) { for (Object attrValue : attributeValues) {
continue; List<Object> attributeValues = attr.getAttributeValue(); if (attributeValues != null) { for (Object attrValue : attributeValues) {
attrMap.put(attr.getFriendlyName(), attr.getAttributeValue()); } else { attrMap.put(attr.getName(), attr.getAttributeValue());
attrMap.put(attr.getFriendlyName(), attr.getAttributeValue()); attrMap.put(attr.getName(), attr.getAttributeValue());
attrMap.put(attr.getFriendlyName(), attr.getAttributeValue()); attrMap.put(attr.getName(), attr.getAttributeValue());
values.addAll(attr.getAttributeValue());
for (ASTChoiceType astChoiceType : attributes) { if (astChoiceType.getAttribute() != null && astChoiceType.getAttribute().getName().equals("Role")) { //$NON-NLS-1$ List<Object> values = astChoiceType.getAttribute().getAttributeValue(); for (Object roleValue : values) { if (roleValue != null) {
continue; List<Object> attributeValues = attr.getAttributeValue(); if (attributeValues != null) { for (Object attrValue : attributeValues) {
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; } } }
List<Object> attributeValues = attributeType.getAttributeValue(); if (attributeValues != null) { for (Object attributeValue : attributeValues) {
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; } } }
List<Object> attributeValues = attributeType.getAttributeValue(); if (attributeValues != null) { for (Object attributeValue : attributeValues) {
/** * Consumes the assertion, resulting in the extraction of the Subject as the JAAS principal and the Role Statements as the JAAS * roles. * * @param assertion * * @throws Exception */ private void consumeAssertion(AssertionType assertion) throws Exception { SubjectType samlSubjectType = assertion.getSubject(); String samlSubject = ((NameIDType) samlSubjectType.getSubType().getBaseID()).getValue(); identity = createIdentity(samlSubject); Set<StatementAbstractType> statements = assertion.getStatements(); for (StatementAbstractType statement : statements) { if (statement instanceof AttributeStatementType) { AttributeStatementType attrStatement = (AttributeStatementType) statement; List<ASTChoiceType> attributes = attrStatement.getAttributes(); for (ASTChoiceType astChoiceType : attributes) { if (astChoiceType.getAttribute() != null && astChoiceType.getAttribute().getName().equals("Role")) { List<Object> values = astChoiceType.getAttribute().getAttributeValue(); for (Object roleValue : values) { if (roleValue != null) { roles.add(roleValue.toString()); } } } } } } }
/** * Consumes the assertion, resulting in the extraction of the Subject as the * JAAS principal and the Role Statements as the JAAS roles. * @param assertion * @throws Exception */ private void consumeAssertion(AssertionType assertion) throws Exception { SubjectType samlSubjectType = assertion.getSubject(); String samlSubject = ((NameIDType) samlSubjectType.getSubType().getBaseID()).getValue(); identity = createIdentity(samlSubject); Set<StatementAbstractType> statements = assertion.getStatements(); for (StatementAbstractType statement : statements) { if (statement instanceof AttributeStatementType) { AttributeStatementType attrStatement = (AttributeStatementType) statement; List<ASTChoiceType> attributes = attrStatement.getAttributes(); for (ASTChoiceType astChoiceType : attributes) { if (astChoiceType.getAttribute() != null && astChoiceType.getAttribute().getName().equals("Role")) { //$NON-NLS-1$ List<Object> values = astChoiceType.getAttribute().getAttributeValue(); for (Object roleValue : values) { if (roleValue != null) { roles.add(roleValue.toString()); } } } } } } }
/** * Consumes the assertion, resulting in the extraction of the Subject as the JAAS principal and the Role Statements as the JAAS * roles. * * @param assertion * * @throws Exception */ private void consumeAssertion(AssertionType assertion) throws Exception { SubjectType samlSubjectType = assertion.getSubject(); String samlSubject = ((NameIDType) samlSubjectType.getSubType().getBaseID()).getValue(); identity = createIdentity(samlSubject); Set<StatementAbstractType> statements = assertion.getStatements(); for (StatementAbstractType statement : statements) { if (statement instanceof AttributeStatementType) { AttributeStatementType attrStatement = (AttributeStatementType) statement; List<ASTChoiceType> attributes = attrStatement.getAttributes(); for (ASTChoiceType astChoiceType : attributes) { if (astChoiceType.getAttribute() != null && astChoiceType.getAttribute().getName().equals("Role")) { List<Object> values = astChoiceType.getAttribute().getAttributeValue(); for (Object roleValue : values) { if (roleValue != null) { roles.add(roleValue.toString()); } } } } } } }
for (ASTChoiceType astChoiceType : attributes) { if (astChoiceType.getAttribute() != null && astChoiceType.getAttribute().getName().equals("Role")) { //$NON-NLS-1$ List<Object> values = astChoiceType.getAttribute().getAttributeValue(); for (Object roleValue : values) { if (roleValue != null) {
for (Object value : attribute.getAttributeValue()) { rolesGroup.addRole(new SimpleRole((String) value));
for (Object value : attribute.getAttributeValue()) { rolesGroup.addRole(new SimpleRole((String) value));