@Override
    public Optional<IndirectClient> locate(final DynamicDiscoveryProviderRequest request, final WebContext webContext) throws Throwable {
        val resource = properties.getAuthn().getPac4j().getCore().getDiscoverySelection().getJson().getLocation();
        try (val in = resource.getInputStream()) {
            val mappings = MAPPER.readValue(in,
                new TypeReference<Map<String, DelegatedAuthenticationDynamicDiscoveryProvider>>() {
                });
            val principal = resolvePrincipal(request);
            LOGGER.debug("Resolved principal to be [{}]", principal);
            return mappings
                .entrySet()
                .stream()
                .sorted(Comparator.comparingInt(o -> o.getValue().getOrder()))
                .map(entry -> getMatchingProvider(principal, entry.getKey(), entry.getValue()))
                .filter(Objects::nonNull)
                .map(provider -> identityProviders.findClient(provider.getClientName(), webContext))
                .flatMap(Optional::stream)
                .map(IndirectClient.class::cast)
                .findFirst();
        }
    }
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