Search in sources :

Example 6 with SoapSTSInstanceConfig

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);
}
Also used : SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) ThreadLocalAMTokenCache(org.forgerock.openam.sts.token.ThreadLocalAMTokenCache) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 7 with SoapSTSInstanceConfig

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);
}
Also used : SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with SoapSTSInstanceConfig

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);
}
Also used : SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 9 with SoapSTSInstanceConfig

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));
}
Also used : SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) Server(org.apache.cxf.endpoint.Server) SecurityTokenServiceProvider(org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 10 with SoapSTSInstanceConfig

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();
}
Also used : SoapSTSKeystoreConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSKeystoreConfig) SAML2Config(org.forgerock.openam.sts.config.user.SAML2Config) SoapSTSInstanceConfig(org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig) AuthTargetMapping(org.forgerock.openam.sts.config.user.AuthTargetMapping) HashMap(java.util.HashMap) SoapDeploymentConfig(org.forgerock.openam.sts.soap.config.user.SoapDeploymentConfig)

Aggregations

SoapSTSInstanceConfig (org.forgerock.openam.sts.soap.config.user.SoapSTSInstanceConfig)15 Test (org.testng.annotations.Test)8 HashMap (java.util.HashMap)5 STSPublishException (org.forgerock.openam.sts.STSPublishException)4 AuthTargetMapping (org.forgerock.openam.sts.config.user.AuthTargetMapping)3 SAML2Config (org.forgerock.openam.sts.config.user.SAML2Config)3 SoapDeploymentConfig (org.forgerock.openam.sts.soap.config.user.SoapDeploymentConfig)3 SoapSTSKeystoreConfig (org.forgerock.openam.sts.soap.config.user.SoapSTSKeystoreConfig)3 ThreadLocalAMTokenCache (org.forgerock.openam.sts.token.ThreadLocalAMTokenCache)3 Logger (org.slf4j.Logger)3 BeforeTest (org.testng.annotations.BeforeTest)3 Map (java.util.Map)2 Server (org.apache.cxf.endpoint.Server)2 SecurityTokenServiceProvider (org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider)2 JsonValue (org.forgerock.json.JsonValue)2 BadRequestException (org.forgerock.json.resource.BadRequestException)2 NotFoundException (org.forgerock.json.resource.NotFoundException)2 HashSet (java.util.HashSet)1 JsonException (org.forgerock.json.JsonException)1 JsonPointer (org.forgerock.json.JsonPointer)1