Search in sources :

Example 1 with OidcAttributeToScopeClaimMapper

use of org.apereo.cas.oidc.claims.mapping.OidcAttributeToScopeClaimMapper in project cas by apereo.

the class BaseOidcScopeAttributeReleasePolicy method mapClaimToAttribute.

private Pair<String, Object> mapClaimToAttribute(final String claim, final Map<String, Object> resolvedAttributes) {
    final ApplicationContext applicationContext = ApplicationContextProvider.getApplicationContext();
    final OidcAttributeToScopeClaimMapper attributeToScopeClaimMapper = applicationContext.getBean("oidcAttributeToScopeClaimMapper", OidcAttributeToScopeClaimMapper.class);
    LOGGER.debug("Attempting to process claim [{}]", claim);
    if (attributeToScopeClaimMapper.containsMappedAttribute(claim)) {
        final String mappedAttr = attributeToScopeClaimMapper.getMappedAttribute(claim);
        final Object value = resolvedAttributes.get(mappedAttr);
        LOGGER.debug("Found mapped attribute [{}] with value [{}] for claim [{}]", mappedAttr, value, claim);
        return Pair.of(claim, value);
    }
    final Object value = resolvedAttributes.get(claim);
    LOGGER.debug("No mapped attribute is defined for claim [{}]; Used [{}] to locate value [{}]", claim, claim, value);
    return Pair.of(claim, value);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) ToString(lombok.ToString) OidcAttributeToScopeClaimMapper(org.apereo.cas.oidc.claims.mapping.OidcAttributeToScopeClaimMapper)

Aggregations

ToString (lombok.ToString)1 OidcAttributeToScopeClaimMapper (org.apereo.cas.oidc.claims.mapping.OidcAttributeToScopeClaimMapper)1 ApplicationContext (org.springframework.context.ApplicationContext)1