Search in sources :

Example 1 with ConvertCasePrincipalNameTransformer

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");
}
Also used : ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) Test(org.junit.Test)

Example 2 with ConvertCasePrincipalNameTransformer

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

Example 3 with ConvertCasePrincipalNameTransformer

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");
}
Also used : ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) Test(org.junit.Test)

Example 4 with ConvertCasePrincipalNameTransformer

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");
}
Also used : ConvertCasePrincipalNameTransformer(org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer) PrefixSuffixPrincipalNameTransformer(org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer) Test(org.junit.Test)

Aggregations

ConvertCasePrincipalNameTransformer (org.apereo.cas.util.transforms.ConvertCasePrincipalNameTransformer)4 Test (org.junit.Test)3 PrefixSuffixPrincipalNameTransformer (org.apereo.cas.util.transforms.PrefixSuffixPrincipalNameTransformer)2 PrincipalNameTransformer (org.apereo.cas.authentication.handler.PrincipalNameTransformer)1