@Operation(summary = "Generate IdP metadata",
        parameters = @Parameter(name = "service", in = ParameterIn.QUERY, required = false, description = "Service identifier"))
    @GetMapping(path = SamlIdPConstants.ENDPOINT_IDP_METADATA, produces = CONTENT_TYPE)
    public void generateMetadataForIdp(
        @RequestParam(value = "service", required = false) final String service,
        final HttpServletResponse response) throws Throwable {

        val registeredService = getRegisteredServiceIfAny(service);
        metadataAndCertificatesGenerationService.generate(registeredService);
        response.setContentType(CONTENT_TYPE);
        response.setStatus(HttpServletResponse.SC_OK);
        try (val md = samlIdPMetadataLocator.resolveMetadata(registeredService).getInputStream()) {
            val contents = IOUtils.toString(md, StandardCharsets.UTF_8);
            try (val writer = response.getWriter()) {
                LOGGER.debug("Producing metadata for the response");
                writer.write(contents);
                writer.flush();
            }
        }
    }
Displays the identity provider metadata.
Checks to make sure metadata exists, and if not, generates it first.

@param service  the service
@param response servlet response
@throws Exception the exception
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/metadata/SamlIdPMetadataController.java