@Override
    public DelegatedClientIdentityProviderConfiguration getProvider(final String entityID,
                                                                    final HttpServletRequest request,
                                                                    final HttpServletResponse response) {
        val idp = getDiscoveryFeed(request, response)
            .stream()
            .filter(entity -> entity.getEntityID().equals(entityID))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No identity provider found for discovery feed's entity ID: " + entityID));

        val context = new JEEContext(request, response);
        val samlClient = identityProviders.findAllClients(context)
            .stream()
            .filter(SAML2Client.class::isInstance)
            .map(SAML2Client.class::cast)
            .peek(InitializableObject::init)
            .filter(c -> c.getIdentityProviderResolvedEntityId().equalsIgnoreCase(idp.getEntityID()))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("No SAML identity provider found for entity ID: " + entityID));

        val webContext = new JEEContext(request, response);
        val service = argumentExtractor.extractService(request);

        val authorized = authorizers
            .stream()
            .allMatch(Unchecked.predicate(authz -> authz.isDelegatedClientAuthorizedForService(samlClient, service, request)));

        if (authorized) {
            val provider = DelegatedClientIdentityProviderConfigurationFactory.builder()
                .service(service)
                .client(samlClient)
                .webContext(webContext)
                .casProperties(casProperties)
                .build()
                .resolve();

            if (provider.isPresent()) {
                return provider.get();
            }
        }
        throw UnauthorizedServiceException.denied("Denied: %s".formatted(entityID));
    }
This is {@link DefaultSamlIdentityProviderDiscoveryFeedService}.

@author Sam Hough
@since 6.6.0
support/cas-server-support-saml-idp-discovery/src/main/java/org/apereo/cas/services/DefaultSamlIdentityProviderDiscoveryFeedService.java