public static ChainingMetadataResolver buildChainingMetadataResolver(final SAML2MetadataResolver idpMetadataProvider,
                                                                         final SAML2MetadataResolver spMetadataProvider) {
        val metadataManager = new ChainingMetadataResolver();
        metadataManager.setId(ChainingMetadataResolver.class.getCanonicalName());
        try {
            final List<MetadataResolver> list = new ArrayList<>();
            list.add(idpMetadataProvider.resolve());
            list.add(spMetadataProvider.resolve());
            metadataManager.setResolvers(list);
            metadataManager.initialize();
        } catch (final ResolverException e) {
            throw new TechnicalException("Error adding idp or sp metadatas to manager", e);
        } catch (final ComponentInitializationException e) {
            throw new TechnicalException("Error initializing manager", e);
        }
        return metadataManager;
    }
<p>buildChainingMetadataResolver.</p>

@param idpMetadataProvider a {@link SAML2MetadataResolver} object
@param spMetadataProvider a {@link SAML2MetadataResolver} object
@return a {@link ChainingMetadataResolver} object
pac4j-saml/src/main/java/org/pac4j/saml/util/SAML2Utils.java