class SAML2HttpUrlKeystoreGenerator extends BaseSAML2KeystoreGenerator {

    /**
     * <p>Constructor for SAML2HttpUrlKeystoreGenerator.</p>
     *
     * @param configuration a {@link SAML2Configuration} object
     */
    public SAML2HttpUrlKeystoreGenerator(final SAML2Configuration configuration) {
        super(configuration);
    }

    /** {@inheritDoc} */
    @Override
    public InputStream retrieve() throws Exception {
        validate();

        val url = saml2Configuration.getKeystoreResource().getURL().toExternalForm();
        logger.debug("Loading keystore from {}", url);
        ClassicHttpRequest httpGet = new HttpGet(url);
        httpGet.addHeader("Accept", ContentType.TEXT_PLAIN.getMimeType());
        httpGet.addHeader("Content-Type", ContentType.TEXT_PLAIN.getMimeType());
        return saml2Configuration.getHttpClient().execute(httpGet, response -> {
            try {
                if (response != null) {
                    val code = response.getCode();
                    if (code == HttpStatus.SC_OK) {
                        logger.info("Successfully submitted/created keystore to {}", url);
                        val results = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
                        return new ByteArrayInputStream(Base64.getDecoder().decode(results));
                    }
                }
                throw new SAMLException("Unable to retrieve keystore from " + url);
            } finally {
                if (response != null && response instanceof CloseableHttpResponse) {
                    response.close();
                }
            }
        });
    }

    /** {@inheritDoc} */
    @Override
    protected void store(final KeyStore ks, final X509Certificate certificate,
                         final PrivateKey privateKey) throws Exception {<FILL_FUNCTION_BODY>}

    private void validate() {
        CommonHelper.assertNotNull("keystoreResource", saml2Configuration.getKeystoreResource());
        CommonHelper.assertNotBlank("keystorePassword", saml2Configuration.getPrivateKeyPassword());
        CommonHelper.assertNotBlank("privateKeyPassword", saml2Configuration.getPrivateKeyPassword());
    }
}

        validate();

        HttpResponse response = null;
        try (var out = new ByteArrayOutputStream()) {
            val password = saml2Configuration.getKeystorePassword().toCharArray();
            ks.store(out, password);
            out.flush();
            val content = Base64.getEncoder().encodeToString(out.toByteArray());

            if (logger.isTraceEnabled()) {
                logger.trace("Encoded keystore as base-64: {}", content);
            }

            val url = saml2Configuration.getKeystoreResource().getURL().toExternalForm();
            val httpPost = new HttpPost(url);
            httpPost.addHeader("Accept", ContentType.TEXT_PLAIN.getMimeType());
            httpPost.addHeader("Content-Type", ContentType.TEXT_PLAIN.getMimeType());
            httpPost.setEntity(new StringEntity(content, ContentType.TEXT_PLAIN));
            logger.debug("Submitting keystore to {}", url);

            response = saml2Configuration.getHttpClient().execute(httpPost);
            if (response != null) {
                val code = response.getCode();
                if (code == HttpStatus.SC_NOT_IMPLEMENTED) {
                    logger.info("Storing keystore is not supported/implemented by {}", url);
                } else if (code == HttpStatus.SC_OK || code == HttpStatus.SC_CREATED) {
                    logger.info("Successfully submitted/created keystore to {}", url);
                } else if (code == HttpStatus.SC_NOT_MODIFIED) {
                    logger.info("Keystore was not modified/updated: {}", url);
                } else {
                    logger.error("Unable to store keystore successfully via {}", url);
                }
            }
        } finally {
            if (response != null && response instanceof CloseableHttpResponse) {
                ((CloseableHttpResponse) response).close();
            }
        }
    
<methods>public void <init>(org.pac4j.saml.config.SAML2Configuration) ,public void generate() ,public boolean shouldGenerate() <variables>protected static final java.lang.String CERTIFICATES_PREFIX,protected final org.slf4j.Logger logger,protected final non-sealed org.pac4j.saml.config.SAML2Configuration saml2Configuration