@Override
    public Principal nominate(final List<Principal> principals, final Map<String, List<Object>> attributes) throws Throwable {
        LOGGER.debug("Calculating principal from principals [{}]", principals);
        val result = principals
            .stream()
            .filter(SurrogatePrincipal.class::isInstance)
            .map(SurrogatePrincipal.class::cast)
            .findFirst();
        if (result.isPresent()) {
            val surrogate = result.get();
            
            principals.removeIf(SurrogatePrincipal.class::isInstance);
            val primaryAttributes = new LinkedHashMap<>(surrogate.getPrimary().getAttributes());
            principals.stream()
                .map(principal -> CoreAuthenticationUtils.mergeAttributes(primaryAttributes, principal.getAttributes(), getAttributeMerger()))
                .forEach(primaryAttributes::putAll);
            surrogate.getPrimary().getAttributes().putAll(primaryAttributes);
            LOGGER.debug("Nominated surrogate principal [{}]", surrogate);
            return surrogate;
        }
        return super.nominate(principals, attributes);
    }
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