@Override
    public SamlIdPMetadataDocument fetchInternal(final Optional<SamlRegisteredService> registeredService) {
        val url = StringUtils.appendIfMissing(properties.getUrl(), "/").concat("idp");
        HttpResponse response = null;
        try {
            val parameters = new HashMap<String, String>();
            registeredService.ifPresent(service -> parameters.put("appliesTo", getAppliesToFor(registeredService)));
            val exec = HttpExecutionRequest.builder()
                .basicAuthPassword(properties.getBasicAuthPassword())
                .basicAuthUsername(properties.getBasicAuthUsername())
                .method(HttpMethod.GET)
                .url(url)
                .parameters(parameters)
                .headers(properties.getHeaders())
                .build();
            response = HttpUtils.execute(exec);
            if (response != null) {
                val status = HttpStatus.valueOf(response.getCode());
                if (status.is2xxSuccessful()) {
                    try (val content = ((HttpEntityContainer) response).getEntity().getContent()) {
                        val entity = IOUtils.toString(content, StandardCharsets.UTF_8);
                        val document = MAPPER.readValue(JsonValue.readHjson(entity).toString(), SamlIdPMetadataDocument.class);
                        if (document != null && document.isValid()) {
                            return document;
                        }
                    }
                }
            }
        } catch (final Exception e) {
            LoggingUtils.error(LOGGER, e);
        } finally {
            HttpUtils.close(response);
        }
        return null;
    }
This is {@link RestfulSamlIdPMetadataLocator}.

@author Misagh Moayyed
@since 6.2.0
support/cas-server-support-saml-idp-metadata-rest/src/main/java/org/apereo/cas/support/saml/idp/metadata/RestfulSamlIdPMetadataLocator.java