protected void writeCertificateAndKey(final File certificate, final File key,
                                          final Optional<SamlRegisteredService> registeredService) throws Exception {
        if (certificate.exists()) {
            LOGGER.info("Certificate file [{}] already exists, and will be deleted", certificate.getCanonicalPath());
            FileUtils.forceDelete(certificate);
        }
        if (key.exists()) {
            LOGGER.info("Key file [{}] already exists, and will be deleted", key.getCanonicalPath());
            FileUtils.forceDelete(key);
        }
        LOGGER.debug("Writing SAML2 key file to [{}]", key.getPath());
        LOGGER.debug("Writing SAML2 certificate file to [{}]", certificate.getPath());
        try (val keyWriter = Files.newBufferedWriter(key.toPath(), StandardCharsets.UTF_8);
             val certWriter = Files.newBufferedWriter(certificate.toPath(), StandardCharsets.UTF_8)) {
            getConfigurationContext().getSamlIdPCertificateAndKeyWriter().writeCertificateAndKey(keyWriter, certWriter);
        }
    }
A metadata generator based on a predefined template.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-saml-idp-core/src/main/java/org/apereo/cas/support/saml/idp/metadata/generator/FileSystemSamlIdPMetadataGenerator.java