@Nonnull
    @Override
    @Retryable(retryFor = ResolverException.class, maxAttempts = 3, backoff = @Backoff(delay = 1000, maxDelay = 5000))
    public Iterable<EntityDescriptor> resolve(final CriteriaSet criteria) {
        val filteringCriteria = determineFilteringCriteria(criteria);
        for (val filter : filteringCriteria) {
            val cacheKey = getMetadataCacheKey(filter, criteria);
            LOGGER.debug("Cache key for SAML IdP metadata is [{}]", cacheKey);
            var entities = metadataCache.getIfPresent(cacheKey);
            if (entities != null) {
                return entities;
            }
            entities = FunctionUtils.doUnchecked(() -> resolveMetadata(criteria, filter));
            if (entities != null && Iterables.size(entities) > 0) {
                metadataCache.put(cacheKey, entities);
                return entities;
            }
        }
        return new ArrayList<>();
    }
Determine the criteria to resolve idp metadata.
If the criteria-set contains a service definition to act as an override,
based on the presence of {@link SamlIdPSamlRegisteredServiceCriterion},
that service is positioned first in the list. An empty criteria
is always added to calculate and resolve metadata globally as the last step,
in case an override is not available.

@param criteria criteria set
@return list of optional service definitions
support/cas-server-support-saml-idp-metadata/src/main/java/org/apereo/cas/support/saml/idp/metadata/SamlIdPMetadataResolver.java