@Override
    protected Principal getPrincipalFromAuthentication(final Collection<Authentication> authentications) {
        LOGGER.trace("Calculating principal from authentications [{}]", authentications);
        val result = authentications
            .stream()
            .map(Authentication::getPrincipal)
            .filter(SurrogatePrincipal.class::isInstance)
            .map(SurrogatePrincipal.class::cast)
            .findFirst();
        if (result.isPresent()) {
            val surrogate = result.get().getSurrogate();
            LOGGER.debug("Found surrogate principal [{}]", surrogate);
            return surrogate;
        }
        return super.getPrincipalFromAuthentication(authentications);
    }
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