Search in sources :

Example 16 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class DefaultAuthenticationRequestHandlerTest method addApplicationConfig.

private void addApplicationConfig(AuthenticationContext context) {
    ApplicationConfig applicationConfig = new ApplicationConfig(new ServiceProvider());
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
    applicationConfig.getServiceProvider().setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
    context.getSequenceConfig().setApplicationConfig(applicationConfig);
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider)

Example 17 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class DefaultRequestPathBasedSequenceHandlerTest method testGetSpRoleClaimUriSpMappedClaim.

/*
        Get role claim URI from SP mapped claims
     */
@Test(dataProvider = "spClaimMappingProvider")
public void testGetSpRoleClaimUriSpMappedClaim(Map<String, String> claimMappings, String expectedRoleClaim) throws Exception {
    Util.mockIdentityUtil();
    ApplicationConfig appConfig = mock(ApplicationConfig.class);
    when(appConfig.getClaimMappings()).thenReturn(claimMappings);
    String roleClaim = requestPathBasedSequenceHandler.getSpRoleClaimUri(appConfig);
    assertEquals(roleClaim, expectedRoleClaim);
}
Also used : ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 18 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class DefaultRequestPathBasedSequenceHandlerTest method testGetSpRoleClaimUri.

/*
        Get Service Provider mapped role claim URI
     */
@Test(dataProvider = "spRoleClaimUriProvider")
public void testGetSpRoleClaimUri(String spRoleClaimUri, String expectedRoleClaimUri) throws Exception {
    Util.mockIdentityUtil();
    ApplicationConfig appConfig = mock(ApplicationConfig.class);
    when(appConfig.getRoleClaim()).thenReturn(spRoleClaimUri);
    assertEquals(requestPathBasedSequenceHandler.getSpRoleClaimUri(appConfig), expectedRoleClaimUri);
}
Also used : ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 19 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class DefaultRequestPathBasedSequenceHandlerTest method testHandlePostAuthentication.

@Test(dataProvider = "getPostAuthenticationData")
public void testHandlePostAuthentication(Map<String, String> unfilteredLocalClaims, Map<String, String> mappedAttributes, String subjectClaimUri, String expectedSubjectIdentifier) throws Exception {
    Util.mockIdentityUtil();
    requestPathBasedSequenceHandler = spy(new DefaultRequestPathBasedSequenceHandler());
    doReturn(mappedAttributes).when(requestPathBasedSequenceHandler).handleClaimMappings(any(AuthenticationContext.class));
    doReturn("spRole1,spRole2").when(requestPathBasedSequenceHandler).getServiceProviderMappedUserRoles(any(SequenceConfig.class), anyList());
    ServiceProvider serviceProvider = new ServiceProvider();
    ApplicationConfig applicationConfig = spy(new ApplicationConfig(serviceProvider));
    when(applicationConfig.getSubjectClaimUri()).thenReturn(subjectClaimUri);
    SequenceConfig sequenceConfig = new SequenceConfig();
    sequenceConfig.setApplicationConfig(applicationConfig);
    AuthenticatedUser authenticatedUser = new AuthenticatedUser();
    authenticatedUser.setUserName("alice");
    sequenceConfig.setAuthenticatedUser(new AuthenticatedUser());
    AuthenticationContext context = new AuthenticationContext();
    context.setProperty(FrameworkConstants.UNFILTERED_LOCAL_CLAIM_VALUES, unfilteredLocalClaims);
    context.setSequenceConfig(sequenceConfig);
    ApplicationAuthenticator applicationAuthenticator = mock(ApplicationAuthenticator.class);
    when(applicationAuthenticator.getName()).thenReturn("Authenticator1");
    AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
    authenticatorConfig.setApplicationAuthenticator(applicationAuthenticator);
    AuthenticatedIdPData idPData = new AuthenticatedIdPData();
    idPData.setIdpName("LOCAL");
    idPData.setAuthenticator(authenticatorConfig);
    mockStatic(FrameworkUtils.class);
    when(FrameworkUtils.getMultiAttributeSeparator()).thenReturn(",");
    requestPathBasedSequenceHandler.handlePostAuthentication(request, response, context, idPData);
    assertNotNull(context.getSequenceConfig().getAuthenticatedUser());
    assertEquals(context.getSequenceConfig().getAuthenticatedUser().getAuthenticatedSubjectIdentifier(), expectedSubjectIdentifier);
}
Also used : AuthenticatorConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig) AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) RequestPathApplicationAuthenticator(org.wso2.carbon.identity.application.authentication.framework.RequestPathApplicationAuthenticator) ApplicationAuthenticator(org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthenticatedUser(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser) AuthenticatedIdPData(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedIdPData) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 20 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class Util method mockSequenceConfig.

public static SequenceConfig mockSequenceConfig(Map<String, String> spRoleMappings) {
    SequenceConfig sequenceConfig = spy(new SequenceConfig());
    ApplicationConfig applicationConfig = mock(ApplicationConfig.class);
    ServiceProvider serviceProvider = mock(ServiceProvider.class);
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = mock(LocalAndOutboundAuthenticationConfig.class);
    when(applicationConfig.getApplicationName()).thenReturn("APP");
    when(sequenceConfig.getApplicationConfig()).thenReturn(applicationConfig);
    when(applicationConfig.getRoleMappings()).thenReturn(spRoleMappings);
    when(applicationConfig.getServiceProvider()).thenReturn(serviceProvider);
    when(serviceProvider.getLocalAndOutBoundAuthenticationConfig()).thenReturn(localAndOutboundAuthenticationConfig);
    when(localAndOutboundAuthenticationConfig.isUseUserstoreDomainInRoles()).thenReturn(false);
    return sequenceConfig;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)

Aggregations

ApplicationConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig)25 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)11 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Test (org.testng.annotations.Test)7 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)6 ArrayList (java.util.ArrayList)5 FrameworkException (org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException)5 HashMap (java.util.HashMap)4 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)4 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)4 StepConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig)4 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)4 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)4 PostAuthenticationFailedException (org.wso2.carbon.identity.application.authentication.framework.exception.PostAuthenticationFailedException)3 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)3 List (java.util.List)2 Map (java.util.Map)2 ApplicationAuthenticator (org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator)2 ExternalIdPConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig)2