use of org.maxkey.entity.ExtraAttr in project MaxKey by dromara.
the class AttributeStatementGenerator method generateAttributeStatement.
public AttributeStatement generateAttributeStatement(AppsSAML20Details saml20Details, ArrayList<GrantedAuthority> grantedAuthoritys, HashMap<String, String> attributeMap) {
AttributeStatementBuilder attributeStatementBuilder = (AttributeStatementBuilder) builderFactory.getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
Attribute attributeGrantedAuthority = builderGrantedAuthority(grantedAuthoritys);
attributeStatement.getAttributes().add(attributeGrantedAuthority);
putUserAttributes(attributeMap);
if (null != attributeMap) {
Iterator<Entry<String, String>> iterator = attributeMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, String> entry = (Map.Entry<String, String>) iterator.next();
String key = entry.getKey();
String value = entry.getValue();
Attribute attribute = builderAttribute(key, value, Attribute.BASIC);
attributeStatement.getAttributes().add(attribute);
}
}
logger.debug("ExtendAttr " + saml20Details.getExtendAttr());
if (ConstsBoolean.isTrue(saml20Details.getIsExtendAttr()) && saml20Details.getExtendAttr() != null) {
ExtraAttrs extraAttrs = new ExtraAttrs(saml20Details.getExtendAttr());
for (ExtraAttr extraAttr : extraAttrs.getExtraAttrs()) {
extraAttr.setValue(extraAttr.getValue().replaceAll(COMMA_ISO8859_1, COMMA));
logger.debug("Attribute : {} , Vale : {} , Type : {}", extraAttr.getAttr(), extraAttr.getValue(), extraAttr.getType());
attributeStatement.getAttributes().add(builderAttribute(extraAttr.getAttr(), extraAttr.getValue(), extraAttr.getType()));
}
}
return attributeStatement;
}
Aggregations