protected DOMMetadataResolver initializeMetadataResolver() {
        if (configuration.getIdentityProviderMetadataResource() instanceof UrlResource urlResource) {
            var fileUrl = urlResource.getURL().toString();
            HttpURLConnection conn = null;
            try {
                conn = (HttpURLConnection) new URL(fileUrl).openConnection();
                if (conn instanceof HttpsURLConnection https) {
                    if (hostnameVerifier != null) {
                        https.setHostnameVerifier(hostnameVerifier);
                    }
                    if (sslSocketFactory != null) {
                        https.setSSLSocketFactory(sslSocketFactory);
                    }
                }
                conn.setRequestMethod("HEAD");
                var supportsRange = "bytes".equalsIgnoreCase(conn.getHeaderField("Accept-Ranges"));
                if (supportsRange) {
                    var contentLength = conn.getContentLengthLong();
                    conn.disconnect();
                    return downloadMetadata(contentLength, fileUrl);
                }
            } catch (Exception e) {
                throw new TechnicalException("Error getting idp metadata resource", e);
            } finally {
                if (conn != null) {
                    conn.disconnect();
                }
            }
        }

        return loadMetadataFromResource(configuration.getIdentityProviderMetadataResource());
    }
Resolve and download idp metadata to form a metadata resolver.
<p>
The resolver supports proxies using {@link Proxy} when fetching metadata over URL resources.

@author Misagh Moayyed
@since 1.7
pac4j-saml/src/main/java/org/pac4j/saml/metadata/SAML2IdentityProviderMetadataResolver.java