use of org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig in project OpenAM by OpenRock.
the class TokenDelegationHandlersProviderTest method testWrappedCustomDelegationHandler.
@Test
public void testWrappedCustomDelegationHandler() throws UnsupportedEncodingException {
Logger mockLogger = mock(Logger.class);
ThreadLocalAMTokenCache mockTokenCache = mock(ThreadLocalAMTokenCache.class);
SoapSTSInstanceConfig instanceConfig = createInstanceConfig(!DELEGATION_VALIDATORS_SPECIFIED, CUSTOM_DELEGATION_HANDLER);
assertTrue(new TokenDelegationHandlersProvider(instanceConfig, mockTokenCache, mockLogger).get().get(0) instanceof CustomDelegationHandlerWrapper);
}
use of org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig in project OpenAM by OpenRock.
the class SoapSTSInstanceStateProviderTest method verifyCaching.
@Test
public void verifyCaching() throws TokenCreationException, STSPublishException, UnsupportedEncodingException {
SoapSTSInstanceConfig instanceConfig = createInstanceConfig();
when(mockConfigStore.getSTSInstanceConfig(DEPLOYMENT_URL_ELEMENT, REALM)).thenReturn(instanceConfig);
//initializes the cache with the mocked config
provider.getSTSInstanceState(DEPLOYMENT_URL_ELEMENT, REALM);
verify(mockConfigStore, times(1)).getSTSInstanceConfig(DEPLOYMENT_URL_ELEMENT, REALM);
//now insure that the config store will return null, to insure that only the cache can return a valid result
when(mockConfigStore.getSTSInstanceConfig(DEPLOYMENT_URL_ELEMENT, REALM)).thenReturn(null);
assertEquals(provider.getSTSInstanceState(DEPLOYMENT_URL_ELEMENT, REALM).getConfig(), instanceConfig);
//the mockConfigStore should only have been called once, with the first invocation of provider.getSTSInstanceState -
//the second call should be resolved in the caching layer.
verify(mockConfigStore, times(1)).getSTSInstanceConfig(DEPLOYMENT_URL_ELEMENT, REALM);
}
use of org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig in project OpenAM by OpenRock.
the class SoapSTSInstanceStateProviderTest method verifyLookup.
@Test
public void verifyLookup() throws TokenCreationException, STSPublishException, UnsupportedEncodingException {
SoapSTSInstanceConfig instanceConfig = createInstanceConfig();
when(mockConfigStore.getSTSInstanceConfig(DEPLOYMENT_URL_ELEMENT, REALM)).thenReturn(instanceConfig);
assertEquals(provider.getSTSInstanceState(DEPLOYMENT_URL_ELEMENT, REALM).getConfig(), instanceConfig);
}
use of org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig in project OpenAM by OpenRock.
the class SoapSTSInstancePublisherImplTest method testNoUpdate.
@SuppressWarnings("unchecked")
@Test
public void testNoUpdate() throws ResourceException, UnsupportedEncodingException {
SoapSTSInstanceConfig instanceConfig = createInstanceConfig("instanceOne", "http://host.com:8080/am");
Set<SoapSTSInstanceConfig> initialSet = Sets.newHashSet(instanceConfig);
when(mockPublishServiceConsumer.getPublishedInstances()).thenReturn(initialSet);
when(mockLifecycleManager.exposeSTSInstanceAsWebService(any(Map.class), any(SecurityTokenServiceProvider.class), any(SoapSTSInstanceConfig.class))).thenReturn(mockServer);
instancePublisher.run();
verify(mockLifecycleManager, times(1)).exposeSTSInstanceAsWebService(any(Map.class), any(SecurityTokenServiceProvider.class), any(SoapSTSInstanceConfig.class));
when(mockPublishServiceConsumer.getPublishedInstances()).thenReturn(initialSet);
instancePublisher.run();
verify(mockLifecycleManager, times(1)).exposeSTSInstanceAsWebService(any(Map.class), any(SecurityTokenServiceProvider.class), any(SoapSTSInstanceConfig.class));
verify(mockLifecycleManager, times(0)).destroySTSInstance(any(Server.class));
}
use of org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig in project OpenAM by OpenRock.
the class SoapSTSInstancePublisherImplTest method createInstanceConfig.
private SoapSTSInstanceConfig createInstanceConfig(String uriElement, String amDeploymentUrl) throws UnsupportedEncodingException {
AuthTargetMapping mapping = AuthTargetMapping.builder().addMapping(TokenType.USERNAME, "service", "ldap").build();
SoapDeploymentConfig deploymentConfig = SoapDeploymentConfig.builder().portQName(AMSTSConstants.STANDARD_STS_PORT_QNAME).serviceQName(AMSTSConstants.STANDARD_STS_SERVICE_NAME).wsdlLocation("wsdl_loc").realm("realm").amDeploymentUrl(amDeploymentUrl).uriElement(uriElement).authTargetMapping(mapping).build();
SoapSTSKeystoreConfig keystoreConfig = SoapSTSKeystoreConfig.builder().keystoreFileName("stsstore.jks").keystorePassword("frstssrvkspw".getBytes(AMSTSConstants.UTF_8_CHARSET_ID)).encryptionKeyAlias("frstssrval").encryptionKeyPassword("frstssrvpw".getBytes(AMSTSConstants.UTF_8_CHARSET_ID)).signatureKeyAlias("frstssrval").signatureKeyPassword("frstssrvpw".getBytes(AMSTSConstants.UTF_8_CHARSET_ID)).build();
SoapSTSInstanceConfig.SoapSTSInstanceConfigBuilderBase<?> builder = SoapSTSInstanceConfig.builder();
builder.addSecurityPolicyTokenValidationConfiguration(TokenType.OPENAM, false);
builder.addSecurityPolicyTokenValidationConfiguration(TokenType.USERNAME, true);
builder.addIssueTokenType(TokenType.SAML2);
Map<String, String> attributeMap = new HashMap<>();
attributeMap.put("mail", "email");
attributeMap.put("uid", "id");
SAML2Config saml2Config = SAML2Config.builder().nameIdFormat("transient").tokenLifetimeInSeconds(500000).spEntityId("http://host.com/saml2/sp/entity/id").encryptAssertion(true).signAssertion(true).encryptionAlgorithm("http://www.w3.org/2001/04/xmlenc#aes128-cbc").encryptionKeyAlias("test").signatureKeyAlias("test").signatureKeyPassword("super.secret".getBytes()).encryptionAlgorithmStrength(128).keystoreFile("da/directory/file").keystorePassword("super.secret".getBytes()).attributeMap(attributeMap).idpId("da_idp").build();
return builder.deploymentConfig(deploymentConfig).soapSTSKeystoreConfig(keystoreConfig).saml2Config(saml2Config).build();
}
Aggregations