private static List<OidcRegisteredServiceAttributeReleasePolicy> buildMatchingPolicies(
        final String givenScope,
        final List<RegisteredServiceAttributeReleasePolicy> policies) {
        return policies
            .stream()
            .filter(OidcRegisteredServiceAttributeReleasePolicy.class::isInstance)
            .map(OidcRegisteredServiceAttributeReleasePolicy.class::cast)
            .filter(policy -> policy.getScopeType().equalsIgnoreCase(givenScope)
                || (policy instanceof final OidcCustomScopeAttributeReleasePolicy customPolicy && customPolicy.getScopeName().equals(givenScope)))
            .toList();
    }
This is {@link OidcServiceRegistryListener}.

@author Misagh Moayyed
@since 6.1.0
support/cas-server-support-oidc-core-api/src/main/java/org/apereo/cas/oidc/services/OidcServiceRegistryListener.java