public static PrincipalNameTransformer newPrincipalNameTransformer(final PrincipalTransformationProperties p) {
        val chain = new ChainingPrincipalNameTransformer();

        if (p.getGroovy().getLocation() != null && CasRuntimeHintsRegistrar.notInNativeImage()) {
            val t = new GroovyPrincipalNameTransformer(p.getGroovy().getLocation());
            chain.addTransformer(t);
        }

        if (StringUtils.isNotBlank(p.getPattern())) {
            val t = new RegexPrincipalNameTransformer(SpringExpressionLanguageValueResolver.getInstance().resolve(p.getPattern()));
            chain.addTransformer(t);
        }

        if (StringUtils.isNotBlank(p.getPrefix()) || StringUtils.isNotBlank(p.getSuffix())) {
            val t = new PrefixSuffixPrincipalNameTransformer();
            t.setPrefix(SpringExpressionLanguageValueResolver.getInstance().resolve(p.getPrefix()));
            t.setSuffix(SpringExpressionLanguageValueResolver.getInstance().resolve(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(SpringExpressionLanguageValueResolver.getInstance().resolve(p.getBlockingPattern()));
            chain.addTransformer(t);
        }

        val transformers = ServiceLoader.load(PrincipalNameTransformer.class)
            .stream()
            .map(ServiceLoader.Provider::get)
            .toList();
        chain.addTransformers(transformers);
        return chain;
    }
New principal name transformer.

@param p the p
@return the principal name transformer
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/principal/PrincipalNameTransformerUtils.java