Search in sources :

Example 1 with ExtraAttr

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;
}
Also used : AttributeStatementBuilder(org.opensaml.saml2.core.impl.AttributeStatementBuilder) ExtraAttr(org.maxkey.entity.ExtraAttr) Entry(java.util.Map.Entry) Attribute(org.opensaml.saml2.core.Attribute) AttributeStatement(org.opensaml.saml2.core.AttributeStatement) XSString(org.opensaml.xml.schema.XSString) ExtraAttrs(org.maxkey.entity.ExtraAttrs) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ExtraAttr (org.maxkey.entity.ExtraAttr)1 ExtraAttrs (org.maxkey.entity.ExtraAttrs)1 Attribute (org.opensaml.saml2.core.Attribute)1 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)1 AttributeStatementBuilder (org.opensaml.saml2.core.impl.AttributeStatementBuilder)1 XSString (org.opensaml.xml.schema.XSString)1