use of org.pac4j.saml.util.DefaultConfigurationManager in project pac4j by pac4j.
the class XMLSecSAML2MetadataSignerTests method verifyGeneration.
@Test
public void verifyGeneration() throws Exception {
final ConfigurationManager mgr = new DefaultConfigurationManager();
mgr.configure();
final var configuration = new SAML2Configuration();
configuration.setForceKeystoreGeneration(true);
configuration.setKeystorePath("target/keystore.jks");
configuration.setKeystorePassword("pac4j");
configuration.setPrivateKeyPassword("pac4j");
configuration.setSignMetadata(true);
configuration.setServiceProviderMetadataResource(new FileSystemResource("target/out.xml"));
configuration.setIdentityProviderMetadataResource(new ClassPathResource("idp-metadata.xml"));
configuration.setMetadataSigner(new XMLSecSAML2MetadataSigner(configuration));
configuration.init();
final var metadataGenerator = configuration.toMetadataGenerator();
final var entity = metadataGenerator.buildEntityDescriptor();
assertNotNull(entity);
final var metadata = metadataGenerator.getMetadata(entity);
assertNotNull(metadata);
metadataGenerator.storeMetadata(metadata, configuration.getServiceProviderMetadataResource(), true);
assertNotNull(metadataGenerator.buildMetadataResolver(configuration.getServiceProviderMetadataResource()));
}
Aggregations