@Test public void customize() throws Exception { SAML2SPKeystoreTO keystoreTO = new SAML2SPKeystoreTO.Builder() .keystore(getKeystoreAsString()) .owner("CAS") .build(); WASAML2SPKeystoreService saml2SPKeystoreService = mock(WASAML2SPKeystoreService.class); when(saml2SPKeystoreService.getByOwner(anyString())).thenReturn(keystoreTO); when(saml2SPKeystoreService.set(any())).thenReturn(Response.created(new URI("http: 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: WARestClient restClient = mock(WARestClient.class); SyncopeClient syncopeClient = mock(SyncopeClient.class); when(syncopeClient.getService(WASAML2SPKeystoreService.class)).thenReturn(saml2SPKeystoreService); when(syncopeClient.getService(WASAML2SPMetadataService.class)).thenReturn(saml2SPMetadataService); when(restClient.getSyncopeClient()).thenReturn(syncopeClient); SyncopeWASAML2ClientCustomizer customizer = new SyncopeWASAML2ClientCustomizer(restClient); SAML2Client client = getSAML2Client(); customizer.customize(client); client.init(); assertTrue(client.getConfiguration().getKeystoreGenerator() instanceof SyncopeWASAML2ClientKeystoreGenerator); assertTrue(client.getConfiguration().toMetadataGenerator() instanceof SyncopeWASAML2ClientMetadataGenerator); }
@Override public void customize(final Client<?> client) { if (client instanceof SAML2Client) { LOG.debug("Customizing SAML2 client {}", client.getName()); final SAML2Client saml2Client = (SAML2Client) client; SAML2Configuration configuration = saml2Client.getConfiguration(); configuration.setKeystoreGenerator(new SyncopeWASAML2ClientKeystoreGenerator(restClient, saml2Client)); configuration.setMetadataGenerator(new SyncopeWASAML2ClientMetadataGenerator(restClient, saml2Client)); } }
SyncopeWASAML2ClientCustomizer implements DelegatedClientFactoryCustomizer<Client<?>> { @Override public void customize(final Client<?> client) { if (client instanceof SAML2Client) { LOG.debug("Customizing SAML2 client {}", client.getName()); final SAML2Client saml2Client = (SAML2Client) client; SAML2Configuration configuration = saml2Client.getConfiguration(); configuration.setKeystoreGenerator(new SyncopeWASAML2ClientKeystoreGenerator(restClient, saml2Client)); configuration.setMetadataGenerator(new SyncopeWASAML2ClientMetadataGenerator(restClient, saml2Client)); } } }
SyncopeWASAML2ClientCustomizer implements DelegatedClientFactoryCustomizer<Client<?>> { @Override public void customize(final Client<?> client) { if (client instanceof SAML2Client) { LOG.debug("Customizing SAML2 client {}", client.getName()); final SAML2Client saml2Client = (SAML2Client) client; SAML2Configuration configuration = saml2Client.getConfiguration(); configuration.setKeystoreGenerator(new SyncopeWASAML2ClientKeystoreGenerator(restClient, saml2Client)); configuration.setMetadataGenerator(new SyncopeWASAML2ClientMetadataGenerator(restClient, saml2Client)); } } SyncopeWASAML2ClientCustomizer(final WARestClient restClient); }
SyncopeWASAML2ClientCustomizer implements DelegatedClientFactoryCustomizer<Client<?>> { @Override public void customize(final Client<?> client) { if (client instanceof SAML2Client) { LOG.debug("Customizing SAML2 client {}", client.getName()); final SAML2Client saml2Client = (SAML2Client) client; SAML2Configuration configuration = saml2Client.getConfiguration(); configuration.setKeystoreGenerator(new SyncopeWASAML2ClientKeystoreGenerator(restClient, saml2Client)); configuration.setMetadataGenerator(new SyncopeWASAML2ClientMetadataGenerator(restClient, saml2Client)); } } SyncopeWASAML2ClientCustomizer(final WARestClient restClient); @Override void customize(final Client<?> client); }
SyncopeWASAML2ClientCustomizer implements DelegatedClientFactoryCustomizer<Client<?>> { @Override public void customize(final Client<?> client) { if (client instanceof SAML2Client) { LOG.debug("Customizing SAML2 client {}", client.getName()); final SAML2Client saml2Client = (SAML2Client) client; SAML2Configuration configuration = saml2Client.getConfiguration(); configuration.setKeystoreGenerator(new SyncopeWASAML2ClientKeystoreGenerator(restClient, saml2Client)); configuration.setMetadataGenerator(new SyncopeWASAML2ClientMetadataGenerator(restClient, saml2Client)); } } SyncopeWASAML2ClientCustomizer(final WARestClient restClient); @Override void customize(final Client<?> client);  }