@Test
    public void verifyKeystoreGenForNewDirectory() throws Exception {
        final ConfigurationManager mgr = new DefaultConfigurationManager();
        mgr.configure();

        val configuration = new SAML2Configuration();
        configuration.setCertificateSignatureAlg("SHA256withRSA");
        configuration.setForceKeystoreGeneration(true);

        val path = RandomStringUtils.randomAlphabetic(4);
        configuration.setKeystorePath(String.format("%s/%s/keystore.jks", FileUtils.getTempDirectoryPath(), path));

        configuration.setKeystorePassword("pac4j");
        configuration.setPrivateKeyPassword("pac4j");
        configuration.setServiceProviderMetadataResource(new FileSystemResource("target/out.xml"));
        configuration.setIdentityProviderMetadataResource(new ClassPathResource("idp-metadata.xml"));
        configuration.init();

        final SAML2KeystoreGenerator generator =
            new SAML2FileSystemKeystoreGenerator(configuration);
        generator.generate();
        assertTrue(configuration.getKeystoreResource().getFile().exists());
    }
This is {@link SAML2FileSystemKeystoreGeneratorTests}.

@author Misagh Moayyed
pac4j-saml/src/test/java/org/pac4j/saml/metadata/keystore/SAML2FileSystemKeystoreGeneratorTests.java