protected Principal extractPrimaryPrincipal(final Authentication authentication) {
        return authentication.getPrincipal() instanceof final SurrogatePrincipal surrogatePrincipal
            ? surrogatePrincipal.getPrimary()
            : authentication.getPrincipal();
    }
This is {@link SurrogateAuthenticationPrincipalBuilder}.

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