@Test public void storeMetadata() throws Exception { SAML2Client client = getSAML2Client(); String keystoreFile = File.createTempFile("keystore", "jks").getCanonicalPath(); client.getConfiguration().setKeystoreResourceFilepath(keystoreFile); SAML2MetadataGenerator generator = new SyncopeWASAML2ClientMetadataGenerator( getWaRestClient(Response.created(new URI("http: EntityDescriptor entityDescriptor = generator.buildEntityDescriptor(); String metadata = generator.getMetadata(entityDescriptor); assertNotNull(generator.storeMetadata(metadata, null, false)); }
@Override public boolean storeMetadata(final String metadata, final Resource resource, final boolean force) throws Exception { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder(). metadata(metadata). owner(saml2Client.getName()). build(); LOG.debug("Storing metadata {}", metadataTO); Response response = metadataService.set(metadataTO); if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {}", saml2Client.getName()); return true; } if (response.getStatus() == Response.Status.CONFLICT.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {} already exists", saml2Client.getName()); return true; } LOG.error("Unexpected response when storing SAML2 SP metadata: {}\n{}", response.getStatus(), response.getHeaders()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add("Unexpected response when storing SAML2 SP metadata"); throw sce; }
SyncopeWASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator { @Override public boolean storeMetadata(final String metadata, final Resource resource, final boolean force) throws Exception { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder(). metadata(metadata). owner(saml2Client.getName()). build(); LOG.debug("Storing metadata {}", metadataTO); Response response = metadataService.set(metadataTO); if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {}", saml2Client.getName()); return true; } if (response.getStatus() == Response.Status.CONFLICT.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {} already exists", saml2Client.getName()); return true; } LOG.error("Unexpected response when storing SAML2 SP metadata: {}\n{}", response.getStatus(), response.getHeaders()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add("Unexpected response when storing SAML2 SP metadata"); throw sce; } }
SyncopeWASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator { @Override public boolean storeMetadata(final String metadata, final Resource resource, final boolean force) throws Exception { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder(). metadata(metadata). owner(saml2Client.getName()). build(); LOG.debug("Storing metadata {}", metadataTO); Response response = metadataService.set(metadataTO); if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {}", saml2Client.getName()); return true; } if (response.getStatus() == Response.Status.CONFLICT.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {} already exists", saml2Client.getName()); return true; } LOG.error("Unexpected response when storing SAML2 SP metadata: {}\n{}", response.getStatus(), response.getHeaders()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add("Unexpected response when storing SAML2 SP metadata"); throw sce; } SyncopeWASAML2ClientMetadataGenerator(final WARestClient restClient, final SAML2Client saml2Client); }
SyncopeWASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator { @Override public boolean storeMetadata(final String metadata, final Resource resource, final boolean force) throws Exception { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder(). metadata(metadata). owner(saml2Client.getName()). build(); LOG.debug("Storing metadata {}", metadataTO); Response response = metadataService.set(metadataTO); if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {}", saml2Client.getName()); return true; } if (response.getStatus() == Response.Status.CONFLICT.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {} already exists", saml2Client.getName()); return true; } LOG.error("Unexpected response when storing SAML2 SP metadata: {}\n{}", response.getStatus(), response.getHeaders()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add("Unexpected response when storing SAML2 SP metadata"); throw sce; } SyncopeWASAML2ClientMetadataGenerator(final WARestClient restClient, final SAML2Client saml2Client); @Override boolean storeMetadata(final String metadata, final Resource resource, final boolean force); }
SyncopeWASAML2ClientMetadataGenerator extends BaseSAML2MetadataGenerator { @Override public boolean storeMetadata(final String metadata, final Resource resource, final boolean force) throws Exception { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder(). metadata(metadata). owner(saml2Client.getName()). build(); LOG.debug("Storing metadata {}", metadataTO); Response response = metadataService.set(metadataTO); if (response.getStatus() == Response.Status.CREATED.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {}", saml2Client.getName()); return true; } if (response.getStatus() == Response.Status.CONFLICT.getStatusCode()) { LOG.info("Stored metadata for SAML2 SP {} already exists", saml2Client.getName()); return true; } LOG.error("Unexpected response when storing SAML2 SP metadata: {}\n{}", response.getStatus(), response.getHeaders()); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Unknown); sce.getElements().add("Unexpected response when storing SAML2 SP metadata"); throw sce; } SyncopeWASAML2ClientMetadataGenerator(final WARestClient restClient, final SAML2Client saml2Client); @Override boolean storeMetadata(final String metadata, final Resource resource, final boolean force);  }