Search in sources :

Example 6 with ReturnAllowedAttributeReleasePolicy

use of org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy in project cas by apereo.

the class DefaultAttributeReleasePolicyMapper method mapAttributeReleasePolicy.

@Override
public void mapAttributeReleasePolicy(final RegisteredServiceAttributeReleasePolicy policy, final RegisteredServiceEditBean.ServiceData bean) {
    if (policy instanceof AbstractRegisteredServiceAttributeReleasePolicy) {
        final AbstractRegisteredServiceAttributeReleasePolicy attrPolicy = (AbstractRegisteredServiceAttributeReleasePolicy) policy;
        final RegisteredServiceAttributeReleasePolicyEditBean attrPolicyBean = bean.getAttrRelease();
        attrPolicyBean.setReleasePassword(attrPolicy.isAuthorizedToReleaseCredentialPassword());
        attrPolicyBean.setReleaseTicket(attrPolicy.isAuthorizedToReleaseProxyGrantingTicket());
        attrPolicyBean.setExcludeDefault(attrPolicy.isExcludeDefaultAttributes());
        this.attributeFilterMapper.mapAttributeFilter(attrPolicy.getAttributeFilter(), bean);
        this.principalAttributesRepositoryMapper.mapPrincipalRepository(attrPolicy.getPrincipalAttributesRepository(), bean);
        final RegisteredServiceAttributeReleasePolicyStrategyEditBean sBean = attrPolicyBean.getAttrPolicy();
        if (attrPolicy instanceof ScriptedRegisteredServiceAttributeReleasePolicy) {
            final ScriptedRegisteredServiceAttributeReleasePolicy policyS = (ScriptedRegisteredServiceAttributeReleasePolicy) attrPolicy;
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.SCRIPT.toString());
            sBean.setScriptFile(policyS.getScriptFile());
        } else if (attrPolicy instanceof GroovyScriptAttributeReleasePolicy) {
            final GroovyScriptAttributeReleasePolicy policyG = (GroovyScriptAttributeReleasePolicy) attrPolicy;
            sBean.setScriptFile(policyG.getGroovyScript());
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.GROOVY.toString());
        } else if (attrPolicy instanceof ReturnAllAttributeReleasePolicy) {
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.ALL.toString());
        } else if (attrPolicy instanceof ReturnAllowedAttributeReleasePolicy) {
            final ReturnAllowedAttributeReleasePolicy attrPolicyAllowed = (ReturnAllowedAttributeReleasePolicy) attrPolicy;
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.ALLOWED.toString());
            sBean.setAttributes(attrPolicyAllowed.getAllowedAttributes());
        } else if (attrPolicy instanceof ReturnMappedAttributeReleasePolicy) {
            final ReturnMappedAttributeReleasePolicy attrPolicyAllowed = (ReturnMappedAttributeReleasePolicy) attrPolicy;
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.MAPPED.toString());
            sBean.setAttributes(attrPolicyAllowed.getAllowedAttributes());
        } else if (attrPolicy instanceof DenyAllAttributeReleasePolicy) {
            sBean.setType(AbstractRegisteredServiceAttributeReleasePolicyStrategyBean.Types.DENY.toString());
        }
    }
}
Also used : RegisteredServiceAttributeReleasePolicyStrategyEditBean(org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyStrategyEditBean) DenyAllAttributeReleasePolicy(org.apereo.cas.services.DenyAllAttributeReleasePolicy) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) ScriptedRegisteredServiceAttributeReleasePolicy(org.apereo.cas.services.ScriptedRegisteredServiceAttributeReleasePolicy) AbstractRegisteredServiceAttributeReleasePolicy(org.apereo.cas.services.AbstractRegisteredServiceAttributeReleasePolicy) ReturnAllowedAttributeReleasePolicy(org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy) GroovyScriptAttributeReleasePolicy(org.apereo.cas.services.GroovyScriptAttributeReleasePolicy) ReturnMappedAttributeReleasePolicy(org.apereo.cas.services.ReturnMappedAttributeReleasePolicy) RegisteredServiceAttributeReleasePolicyEditBean(org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyEditBean)

Aggregations

ReturnAllowedAttributeReleasePolicy (org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy)6 AbstractRegisteredServiceAttributeReleasePolicy (org.apereo.cas.services.AbstractRegisteredServiceAttributeReleasePolicy)3 DenyAllAttributeReleasePolicy (org.apereo.cas.services.DenyAllAttributeReleasePolicy)3 GroovyScriptAttributeReleasePolicy (org.apereo.cas.services.GroovyScriptAttributeReleasePolicy)3 ReturnAllAttributeReleasePolicy (org.apereo.cas.services.ReturnAllAttributeReleasePolicy)3 ReturnMappedAttributeReleasePolicy (org.apereo.cas.services.ReturnMappedAttributeReleasePolicy)3 ScriptedRegisteredServiceAttributeReleasePolicy (org.apereo.cas.services.ScriptedRegisteredServiceAttributeReleasePolicy)3 RegisteredServiceAttributeReleasePolicyEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyEditBean)2 RegisteredServiceAttributeReleasePolicyStrategyEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyStrategyEditBean)2 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Principal (org.apereo.cas.authentication.principal.Principal)1 PrincipalAttributesRepository (org.apereo.cas.authentication.principal.PrincipalAttributesRepository)1 RegisteredServiceAttributeReleasePolicyViewBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceAttributeReleasePolicyViewBean)1 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)1 DefaultRegisteredServiceUsernameProvider (org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider)1 RegexMatchingRegisteredServiceProxyPolicy (org.apereo.cas.services.RegexMatchingRegisteredServiceProxyPolicy)1 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)1