Search in sources :

Example 1 with PrincipalNameTransformer

use of org.apereo.cas.authentication.handler.PrincipalNameTransformer in project cas by apereo.

the class Beans method newPrincipalNameTransformer.

/**
     * New principal name transformer.
     *
     * @param p the p
     * @return the principal name transformer
     */
public static PrincipalNameTransformer newPrincipalNameTransformer(final PrincipalTransformationProperties p) {
    final PrincipalNameTransformer res;
    if (StringUtils.isNotBlank(p.getPrefix()) || StringUtils.isNotBlank(p.getSuffix())) {
        final PrefixSuffixPrincipalNameTransformer t = new PrefixSuffixPrincipalNameTransformer();
        t.setPrefix(p.getPrefix());
        t.setSuffix(p.getSuffix());
        res = t;
    } else {
        res = formUserId -> formUserId;
    }
    switch(p.getCaseConversion()) {
        case UPPERCASE:
            final ConvertCasePrincipalNameTransformer t = new ConvertCasePrincipalNameTransformer(res);
            t.setToUpperCase(true);
            return t;
        case LOWERCASE:
            final ConvertCasePrincipalNameTransformer t1 = new ConvertCasePrincipalNameTransformer(res);
            t1.setToUpperCase(false);
            return t1;
        default:
    }
    return res;
}
Also used : ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) PrincipalNameTransformer(org.apereo.cas.authentication.handler.PrincipalNameTransformer) PrefixSuffixPrincipalNameTransformer(org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer) PrefixSuffixPrincipalNameTransformer(org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)

Aggregations

PrincipalNameTransformer (org.apereo.cas.authentication.handler.PrincipalNameTransformer)1 ConvertCasePrincipalNameTransformer (org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer)1 PrefixSuffixPrincipalNameTransformer (org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)1