private static void addAttributeReleasePolicy(
        final RegisteredServiceChainingAttributeReleasePolicy chain,
        final BaseOidcScopeAttributeReleasePolicy policyToAdd,
        final String givenScope,
        final OidcRegisteredService registeredService) {
        LOGGER.debug("Mapped [{}] to attribute release policy [{}]",
            givenScope, policyToAdd.getClass().getSimpleName());

        val policy = registeredService.getAttributeReleasePolicy();
        val matchingPolicies = new ArrayList<RegisteredServiceAttributeReleasePolicy>();

        if (policy instanceof final RegisteredServiceChainingAttributeReleasePolicy chainedPolicy) {
            val policiesToAdd = buildMatchingPolicies(givenScope, chainedPolicy.getPolicies());
            matchingPolicies.addAll(policiesToAdd);
        } else if (policy instanceof final OidcRegisteredServiceAttributeReleasePolicy oidcPolicy) {
            val policiesToAdd = buildMatchingPolicies(givenScope, List.of(oidcPolicy));
            matchingPolicies.addAll(policiesToAdd);
        }

        if (matchingPolicies.isEmpty()) {
            policyToAdd.setConsentPolicy(policy.getConsentPolicy());
            policyToAdd.setPrincipalAttributesRepository(policy.getPrincipalAttributesRepository());
            chain.addPolicies(policyToAdd);
        } else {
            chain.addPolicies(matchingPolicies);
        }
    }
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