@Override
    protected Map<String, List<Object>> getPrincipalAttributesForPrincipal(final Collection<Authentication> authentications,
                                                                           final Principal principal,
                                                                           final Map<String, List<Object>> principalAttributes) {
        val result = authentications
            .stream()
            .map(Authentication::getPrincipal)
            .filter(SurrogatePrincipal.class::isInstance)
            .map(SurrogatePrincipal.class::cast)
            .findFirst();
        if (result.isPresent()) {
            return principal.getAttributes();
        }
        return super.getPrincipalAttributesForPrincipal(authentications, principal, principalAttributes);
    }
This is {@link SurrogatePrincipalElectionStrategy}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-surrogate-core/src/main/java/org/apereo/cas/authentication/SurrogatePrincipalElectionStrategy.java