* @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 = JBossSAMLBaseFactory.createAttributeStatement();
i++;
}
AttributeType att = getX500Attribute();
Object value = attributes.get(key);
if(AttributeConstants.EMAIL_ADDRESS.equals(key))
{
att.setFriendlyName(X500SAMLProfileConstants.EMAIL_ADDRESS.getFriendlyName());
att.setName(X500SAMLProfileConstants.EMAIL_ADDRESS.get());
}
else if(AttributeConstants.EMPLOYEE_NUMBER.equals(key))
{
att.setFriendlyName(X500SAMLProfileConstants.EMPLOYEE_NUMBER.getFriendlyName());
att.setName(X500SAMLProfileConstants.EMPLOYEE_NUMBER.get());
}
else if(AttributeConstants.GIVEN_NAME.equals(key))
{
att.setFriendlyName(X500SAMLProfileConstants.GIVENNAME.getFriendlyName());
att.setName(X500SAMLProfileConstants.GIVENNAME.get());
}
else if(AttributeConstants.TELEPHONE.equals(key))
{
att.setFriendlyName(X500SAMLProfileConstants.TELEPHONE.getFriendlyName());
att.setName(X500SAMLProfileConstants.TELEPHONE.get());
}
att.getAttributeValue().add(value);
attrStatement.getAttributeOrEncryptedAttribute().add(att);
}
return attrStatement;
}