Search in sources :

Example 1 with WSFederationClaims

use of org.apereo.cas.ws.idp.WSFederationClaims in project cas by apereo.

the class WSFederationClaimsReleasePolicy method getAttributesInternal.

@Override
public Map<String, Object> getAttributesInternal(final Principal principal, final Map<String, Object> attrs, final RegisteredService service) {
    final Map<String, Object> resolvedAttributes = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    resolvedAttributes.putAll(attrs);
    final Map<String, Object> attributesToRelease = new HashMap<>(resolvedAttributes.size());
    getAllowedAttributes().entrySet().stream().filter(entry -> WSFederationClaims.contains(entry.getKey().toUpperCase())).forEach(entry -> {
        final String claimName = entry.getKey();
        final String attributeName = entry.getValue();
        final WSFederationClaims claim = WSFederationClaims.valueOf(claimName.toUpperCase());
        LOGGER.debug("Evaluating claimName [{}] mapped to attribute name [{}]", claim.getUri(), attributeName);
        final Object value = resolvedAttributes.get(attributeName);
        if (value != null) {
            LOGGER.debug("Adding claimName [{}] to the collection of released attributes", claim.getUri());
            attributesToRelease.put(claim.getUri(), value);
        }
    });
    return attributesToRelease;
}
Also used : AbstractRegisteredServiceAttributeReleasePolicy(org.apereo.cas.services.AbstractRegisteredServiceAttributeReleasePolicy) Slf4j(lombok.extern.slf4j.Slf4j) Setter(lombok.Setter) TreeMap(java.util.TreeMap) Getter(lombok.Getter) Map(java.util.Map) HashMap(java.util.HashMap) Principal(org.apereo.cas.authentication.principal.Principal) RegisteredService(org.apereo.cas.services.RegisteredService) WSFederationClaims(org.apereo.cas.ws.idp.WSFederationClaims) HashMap(java.util.HashMap) WSFederationClaims(org.apereo.cas.ws.idp.WSFederationClaims) TreeMap(java.util.TreeMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Principal (org.apereo.cas.authentication.principal.Principal)1 AbstractRegisteredServiceAttributeReleasePolicy (org.apereo.cas.services.AbstractRegisteredServiceAttributeReleasePolicy)1 RegisteredService (org.apereo.cas.services.RegisteredService)1 WSFederationClaims (org.apereo.cas.ws.idp.WSFederationClaims)1