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;
}
Aggregations