Search in sources :

Example 1 with SamlIdPAttributeDefinition

use of org.apereo.cas.support.saml.web.idp.profile.builders.attr.SamlIdPAttributeDefinition in project cas by apereo.

the class SamlIdPConsentableAttributeBuilder method build.

@Override
public CasConsentableAttribute build(final CasConsentableAttribute attribute) {
    val result = attributeDefinitionStore.locateAttributeDefinition(defn -> {
        if (defn instanceof SamlIdPAttributeDefinition) {
            val samlAttr = (SamlIdPAttributeDefinition) defn;
            return samlAttr.getName().equalsIgnoreCase(attribute.getName()) && StringUtils.isNotBlank(samlAttr.getFriendlyName());
        }
        return false;
    });
    if (result.isPresent()) {
        val samlAttr = (SamlIdPAttributeDefinition) result.get();
        attribute.setFriendlyName(samlAttr.getFriendlyName());
    }
    val attributeValues = ObjectUtils.defaultIfNull(attribute.getValues(), new ArrayList<>());
    attributeValues.replaceAll(o -> {
        if (o instanceof XSString) {
            return ((XSString) o).getValue();
        }
        if (o instanceof XSURI) {
            return ((XSURI) o).getURI();
        }
        if (o instanceof Serializable) {
            return o;
        }
        return o.toString();
    });
    return attribute;
}
Also used : lombok.val(lombok.val) SamlIdPAttributeDefinition(org.apereo.cas.support.saml.web.idp.profile.builders.attr.SamlIdPAttributeDefinition) Serializable(java.io.Serializable) XSString(org.opensaml.core.xml.schema.XSString) XSURI(org.opensaml.core.xml.schema.XSURI)

Aggregations

Serializable (java.io.Serializable)1 lombok.val (lombok.val)1 SamlIdPAttributeDefinition (org.apereo.cas.support.saml.web.idp.profile.builders.attr.SamlIdPAttributeDefinition)1 XSString (org.opensaml.core.xml.schema.XSString)1 XSURI (org.opensaml.core.xml.schema.XSURI)1