public static PrincipalResolutionContext buildPrincipalResolutionContext(
        final ConfigurableApplicationContext applicationContext,
        final PrincipalFactory principalFactory,
        final PersonAttributeDao attributeRepository,
        final AttributeMerger attributeMerger,
        final ServicesManager servicesManager,
        final AttributeDefinitionStore attributeDefinitionStore,
        final AttributeRepositoryResolver attributeRepositoryResolver,
        final PersonDirectoryPrincipalResolverProperties... personDirectory) {

        val transformers = Arrays.stream(personDirectory)
            .map(p -> PrincipalNameTransformerUtils.newPrincipalNameTransformer(p.getPrincipalTransformation()))
            .collect(Collectors.toList());
        val transformer = new ChainingPrincipalNameTransformer(transformers);

        val activeAttributeRepositoryIdentifiers = PrincipalResolverUtils.buildActiveAttributeRepositoryIds(personDirectory);
        return PrincipalResolutionContext.builder()
            .servicesManager(servicesManager)
            .applicationContext(applicationContext)
            .attributeDefinitionStore(attributeDefinitionStore)
            .attributeRepository(attributeRepository)
            .attributeMerger(attributeMerger)
            .principalFactory(principalFactory)
            .returnNullIfNoAttributes(Arrays.stream(personDirectory).filter(p -> p.getReturnNull() != TriStateBoolean.UNDEFINED)
                .map(p -> p.getReturnNull().toBoolean()).findFirst().orElse(Boolean.FALSE))
            .principalAttributeNames(Arrays.stream(personDirectory)
                .map(PersonDirectoryPrincipalResolverProperties::getPrincipalAttribute)
                .filter(StringUtils::isNotBlank)
                .findFirst()
                .orElse(StringUtils.EMPTY))
            .principalNameTransformer(transformer)
            .useCurrentPrincipalId(Arrays.stream(personDirectory).filter(p -> p.getUseExistingPrincipalId() != TriStateBoolean.UNDEFINED)
                .map(p -> p.getUseExistingPrincipalId().toBoolean()).findFirst().orElse(Boolean.FALSE))
            .resolveAttributes(Arrays.stream(personDirectory).filter(p -> p.getAttributeResolutionEnabled() != TriStateBoolean.UNDEFINED)
                .map(p -> p.getAttributeResolutionEnabled().toBoolean()).findFirst().orElse(Boolean.TRUE))
            .activeAttributeRepositoryIdentifiers(activeAttributeRepositoryIdentifiers)
            .attributeRepositoryResolver(attributeRepositoryResolver)
            .tenantExtractor(applicationContext.getBean(TenantExtractor.BEAN_NAME, TenantExtractor.class))
            .build();
    }
Build principal resolution context.

@param applicationContext          the application context
@param principalFactory            the principal factory
@param attributeRepository         the attribute repository
@param attributeMerger             the attribute merger
@param servicesManager             the services manager
@param attributeDefinitionStore    the attribute definition store
@param attributeRepositoryResolver the attribute repository resolver
@param personDirectory             the person directory properties
@return the resolver
support/cas-server-support-person-directory-core/src/main/java/org/apereo/cas/authentication/principal/resolvers/PersonDirectoryPrincipalResolver.java