use of org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer in project cas by apereo.
the class ConvertCasePrincipalNameTransformerTests method verifyUpperCaseTranformerWithTrim.
@Test
public void verifyUpperCaseTranformerWithTrim() {
final ConvertCasePrincipalNameTransformer transformer = new ConvertCasePrincipalNameTransformer();
transformer.init();
transformer.setToUpperCase(true);
final String result = transformer.transform(" uid ");
assertEquals(result, "UID");
}
use of org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer 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;
}
use of org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer in project cas by apereo.
the class ConvertCasePrincipalNameTransformerTests method verifyLowerCaseTranformerWithTrim.
@Test
public void verifyLowerCaseTranformerWithTrim() {
final ConvertCasePrincipalNameTransformer transformer = new ConvertCasePrincipalNameTransformer();
transformer.init();
final String result = transformer.transform(" UID ");
assertEquals(result, "uid");
}
use of org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer in project cas by apereo.
the class ConvertCasePrincipalNameTransformerTests method verifyUpperCaseTranformerWithTrimAndDelegate.
@Test
public void verifyUpperCaseTranformerWithTrimAndDelegate() {
final PrefixSuffixPrincipalNameTransformer suffixTrans = new PrefixSuffixPrincipalNameTransformer();
suffixTrans.setPrefix("a");
suffixTrans.setSuffix("z");
final ConvertCasePrincipalNameTransformer transformer = new ConvertCasePrincipalNameTransformer(suffixTrans);
transformer.setToUpperCase(true);
final String result = transformer.transform(" uid ");
assertEquals(result, "AUIDZ");
}
Aggregations