@Override
    public Map<String, List<Object>> filter(final Map<String, List<Object>> givenAttributes) {
        val attributesToRelease = new HashMap<String, List<Object>>();
        givenAttributes.entrySet().stream().filter(filterProvidedGivenAttributes()).forEach(entry -> {
            val attributeName = entry.getKey();
            if (patterns.containsKey(attributeName)) {
                val attributeValues = CollectionUtils.toCollection(entry.getValue());
                LOGGER.debug("Found attribute [{}] in pattern definitions with value(s) [{}]", attributeName, attributeValues);
                val attributePatterns = createPatternForMappedAttribute(attributeName);
                attributePatterns.forEach(pattern -> {
                    LOGGER.debug("Found attribute [{}] in the pattern definitions. Processing pattern [{}]", attributeName, pattern.pattern());
                    val filteredValues = filterAttributeValuesByPattern(attributeValues, pattern);
                    LOGGER.debug("Filtered attribute values for [{}] are [{}]", attributeName, filteredValues);
                    if (filteredValues.isEmpty()) {
                        LOGGER.debug("Attribute [{}] has no values remaining and shall be excluded", attributeName);
                    } else {
                        collectAttributeWithFilteredValues(attributesToRelease, attributeName, filteredValues);
                    }
                });
            } else {
                handleUnmappedAttribute(attributesToRelease, entry.getKey(), entry.getValue());
            }
        });
        LOGGER.debug("Received [{}] attributes. Filtered and released [{}]", givenAttributes.size(), attributesToRelease.size());
        return attributesToRelease;
    }
A filtering policy that selectively applies patterns to attributes mapped in the config.
If an attribute is mapped, it's only allowed to be released if it matches the linked pattern.
If an attribute is not mapped, it may optionally be excluded from the released set of attributes.

@author Misagh Moayyed
@since 5.1.0
core/cas-server-core-services-api/src/main/java/org/apereo/cas/services/support/RegisteredServiceMappedRegexAttributeFilter.java