@Override
    protected Principal buildResolvedPrincipal(final String id, final Map<String, List<Object>> attributes,
                                               final Credential credential, final Optional<Principal> currentPrincipal,
                                               final Optional<AuthenticationHandler> handler) throws Throwable {
        if (!supports(credential)) {
            return super.buildResolvedPrincipal(id, attributes, credential, currentPrincipal, handler);
        }
        val principal = currentPrincipal.orElseThrow(() -> new IllegalArgumentException("Current principal resolved cannot be empty"));
        return surrogatePrincipalBuilder.buildSurrogatePrincipal(credential, principal);
    }
This is {@link SurrogatePrincipalResolver}.

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