@Test public void fetchMetadata() throws Exception { SAML2Client client = getSAML2Client(); String keystoreFile = File.createTempFile("keystore", "jks").getCanonicalPath(); client.getConfiguration().setKeystoreResourceFilepath(keystoreFile); WARestClient restClient = mock(WARestClient.class); SAML2SPMetadataTO metadataTO = new SAML2SPMetadataTO.Builder() .owner("Syncope") .metadata(IOUtils.toString(new ClassPathResource("sp-metadata.xml").getInputStream(), StandardCharsets.UTF_8)) .build(); WASAML2SPMetadataService saml2SPMetadataService = mock(WASAML2SPMetadataService.class); when(saml2SPMetadataService.getByOwner(anyString())).thenReturn(metadataTO); when(saml2SPMetadataService.set(any())).thenReturn(Response.created(new URI("http: SyncopeClient syncopeClient = mock(SyncopeClient.class); when(syncopeClient.getService(WASAML2SPMetadataService.class)).thenReturn(saml2SPMetadataService); when(restClient.getSyncopeClient()).thenReturn(syncopeClient); SyncopeWASAML2MetadataResolver resolver = new SyncopeWASAML2MetadataResolver(restClient, client); assertNotNull(resolver.fetchMetadata()); }
@Override protected byte[] fetchMetadata() throws ResolverException { try { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = metadataService.getByOwner(saml2Client.getName()); return metadataTO.getMetadata().getBytes(StandardCharsets.UTF_8); } catch (final Exception e) { final String message = "Unable to fetch SP metadata for " + saml2Client.getName(); LOG.error(message, e); throw new ResolverException(message); } }
SyncopeWASAML2MetadataResolver extends AbstractReloadingMetadataResolver { @Override protected byte[] fetchMetadata() throws ResolverException { try { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = metadataService.getByOwner(saml2Client.getName()); return metadataTO.getMetadata().getBytes(StandardCharsets.UTF_8); } catch (final Exception e) { final String message = "Unable to fetch SP metadata for " + saml2Client.getName(); LOG.error(message, e); throw new ResolverException(message); } } }
SyncopeWASAML2MetadataResolver extends AbstractReloadingMetadataResolver { @Override protected byte[] fetchMetadata() throws ResolverException { try { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = metadataService.getByOwner(saml2Client.getName()); return metadataTO.getMetadata().getBytes(StandardCharsets.UTF_8); } catch (final Exception e) { final String message = "Unable to fetch SP metadata for " + saml2Client.getName(); LOG.error(message, e); throw new ResolverException(message); } } SyncopeWASAML2MetadataResolver(final WARestClient restClient, final SAML2Client saml2Client); }
SyncopeWASAML2MetadataResolver extends AbstractReloadingMetadataResolver { @Override protected byte[] fetchMetadata() throws ResolverException { try { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = metadataService.getByOwner(saml2Client.getName()); return metadataTO.getMetadata().getBytes(StandardCharsets.UTF_8); } catch (final Exception e) { final String message = "Unable to fetch SP metadata for " + saml2Client.getName(); LOG.error(message, e); throw new ResolverException(message); } } SyncopeWASAML2MetadataResolver(final WARestClient restClient, final SAML2Client saml2Client);  }
SyncopeWASAML2MetadataResolver extends AbstractReloadingMetadataResolver { @Override protected byte[] fetchMetadata() throws ResolverException { try { WASAML2SPMetadataService metadataService = restClient.getSyncopeClient(). getService(WASAML2SPMetadataService.class); SAML2SPMetadataTO metadataTO = metadataService.getByOwner(saml2Client.getName()); return metadataTO.getMetadata().getBytes(StandardCharsets.UTF_8); } catch (final Exception e) { final String message = "Unable to fetch SP metadata for " + saml2Client.getName(); LOG.error(message, e); throw new ResolverException(message); } } SyncopeWASAML2MetadataResolver(final WARestClient restClient, final SAML2Client saml2Client);   }