protected Principal resolvePrincipal(final Principal principal, final RequestContext requestContext) {
        val resolvers = new ArrayList<>(requestContext.getActiveFlow().getApplicationContext()
            .getBeansOfType(MultifactorAuthenticationPrincipalResolver.class).values());
        AnnotationAwareOrderComparator.sort(resolvers);
        return resolvers
            .stream()
            .filter(resolver -> resolver.supports(principal))
            .findFirst()
            .map(r -> r.resolve(principal))
            .orElse(principal);
    }
This is {@link PopulateSpringSecurityContextAction}.

@author Misagh Moayyed
@since 6.4.0
support/cas-server-support-actions-core/src/main/java/org/apereo/cas/web/flow/PopulateSpringSecurityContextAction.java