Search in sources :

Example 1 with DefaultPrincipalAttributesRepository

use of org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository in project cas by apereo.

the class DefaultPrincipalAttributesRepositoryMapper method toPrincipalRepository.

@Override
public PrincipalAttributesRepository toPrincipalRepository(final RegisteredServiceEditBean.ServiceData data) {
    final RegisteredServiceAttributeReleasePolicyEditBean attrRelease = data.getAttrRelease();
    final RegisteredServiceAttributeReleasePolicyEditBean.Types attrType = attrRelease.getAttrOption();
    if (attrType == RegisteredServiceAttributeReleasePolicyEditBean.Types.CACHED) {
        final CachingPrincipalAttributesRepository r = new CachingPrincipalAttributesRepository(attrRelease.getCachedTimeUnit().toUpperCase(), attrRelease.getCachedExpiration());
        switch(attrRelease.getMergingStrategy()) {
            case ADD:
                r.setMergingStrategy(AbstractPrincipalAttributesRepository.MergingStrategy.ADD);
                break;
            case MULTIVALUED:
                r.setMergingStrategy(AbstractPrincipalAttributesRepository.MergingStrategy.MULTIVALUED);
                break;
            case REPLACE:
                r.setMergingStrategy(AbstractPrincipalAttributesRepository.MergingStrategy.REPLACE);
                break;
            default:
                r.setMergingStrategy(AbstractPrincipalAttributesRepository.MergingStrategy.NONE);
                break;
        }
        return r;
    }
    if (attrType == RegisteredServiceAttributeReleasePolicyEditBean.Types.DEFAULT) {
        return new DefaultPrincipalAttributesRepository();
    }
    return null;
}
Also used : DefaultPrincipalAttributesRepository(org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository) RegisteredServiceAttributeReleasePolicyEditBean(org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyEditBean) CachingPrincipalAttributesRepository(org.apereo.cas.authentication.principal.cache.CachingPrincipalAttributesRepository)

Aggregations

DefaultPrincipalAttributesRepository (org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository)1 CachingPrincipalAttributesRepository (org.apereo.cas.authentication.principal.cache.CachingPrincipalAttributesRepository)1 RegisteredServiceAttributeReleasePolicyEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyEditBean)1