Search in sources :

Example 1 with GroovyPrincipalNameTransformer

use of org.apereo.cas.util.transforms.GroovyPrincipalNameTransformer in project cas by apereo.

the class PrincipalNameTransformerUtils method newPrincipalNameTransformer.

/**
 * New principal name transformer.
 *
 * @param p the p
 * @return the principal name transformer
 */
public static PrincipalNameTransformer newPrincipalNameTransformer(final PrincipalTransformationProperties p) {
    val chain = new ChainingPrincipalNameTransformer();
    if (p.getGroovy().getLocation() != null) {
        val t = new GroovyPrincipalNameTransformer(p.getGroovy().getLocation());
        chain.addTransformer(t);
    }
    if (StringUtils.isNotBlank(p.getPattern())) {
        val t = new RegexPrincipalNameTransformer(p.getPattern());
        chain.addTransformer(t);
    }
    if (StringUtils.isNotBlank(p.getPrefix()) || StringUtils.isNotBlank(p.getSuffix())) {
        val t = new PrefixSuffixPrincipalNameTransformer();
        t.setPrefix(p.getPrefix());
        t.setSuffix(p.getSuffix());
        chain.addTransformer(t);
    }
    if (p.getCaseConversion() == PrincipalTransformationProperties.CaseConversion.UPPERCASE) {
        val t = new ConvertCasePrincipalNameTransformer();
        t.setToUpperCase(true);
        chain.addTransformer(t);
    }
    if (p.getCaseConversion() == PrincipalTransformationProperties.CaseConversion.LOWERCASE) {
        val t = new ConvertCasePrincipalNameTransformer();
        t.setToUpperCase(false);
        chain.addTransformer(t);
    }
    if (StringUtils.isNotBlank(p.getBlockingPattern())) {
        val t = new BlockingPrincipalNameTransformer(p.getBlockingPattern());
        chain.addTransformer(t);
    }
    return chain;
}
Also used : lombok.val(lombok.val) RegexPrincipalNameTransformer(org.apereo.cas.util.transforms.RegexPrincipalNameTransformer) ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) GroovyPrincipalNameTransformer(org.apereo.cas.util.transforms.GroovyPrincipalNameTransformer) BlockingPrincipalNameTransformer(org.apereo.cas.util.transforms.BlockingPrincipalNameTransformer) ChainingPrincipalNameTransformer(org.apereo.cas.util.transforms.ChainingPrincipalNameTransformer) PrefixSuffixPrincipalNameTransformer(org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)

Aggregations

lombok.val (lombok.val)1 BlockingPrincipalNameTransformer (org.apereo.cas.util.transforms.BlockingPrincipalNameTransformer)1 ChainingPrincipalNameTransformer (org.apereo.cas.util.transforms.ChainingPrincipalNameTransformer)1 ConvertCasePrincipalNameTransformer (org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer)1 GroovyPrincipalNameTransformer (org.apereo.cas.util.transforms.GroovyPrincipalNameTransformer)1 PrefixSuffixPrincipalNameTransformer (org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)1 RegexPrincipalNameTransformer (org.apereo.cas.util.transforms.RegexPrincipalNameTransformer)1