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;
}
Aggregations