protected Principal resolvePrincipal(final DynamicDiscoveryProviderRequest request) throws Throwable {
        val userId = request.getUserId();
        val resolvedPrincipal = principalResolver.resolve(new BasicIdentifiableCredential(userId));

        if (resolvedPrincipal instanceof NullPrincipal) {
            LOGGER.debug("No principal was resolved. Falling back to the username [{}] from the credentials.", userId);
            return clientPrincipalFactory.createPrincipal(userId);
        }

        return resolvedPrincipal;
    }
This is {@link DefaultDelegatedAuthenticationDynamicDiscoveryProviderLocator}.

@author Misagh Moayyed
@since 6.5.0
support/cas-server-support-pac4j-core/src/main/java/org/apereo/cas/pac4j/discovery/DefaultDelegatedAuthenticationDynamicDiscoveryProviderLocator.java