Search in sources :

Example 26 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class ApplicationDAOImpl method getBasicApplicationData.

/**
 * @param appId
 * @param connection
 * @return
 * @throws SQLException
 */
private ServiceProvider getBasicApplicationData(int appId, Connection connection) throws SQLException, IdentityApplicationManagementException {
    ServiceProvider serviceProvider = null;
    if (log.isDebugEnabled()) {
        log.debug("Loading Basic Application Data of application ID: " + appId);
    }
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    try {
        prepStmt = connection.prepareStatement(LOAD_BASIC_APP_INFO_BY_APP_ID);
        prepStmt.setInt(1, appId);
        rs = prepStmt.executeQuery();
        if (rs.next()) {
            serviceProvider = new ServiceProvider();
            serviceProvider.setApplicationID(rs.getInt(ApplicationTableColumns.ID));
            serviceProvider.setApplicationResourceId(rs.getString(ApplicationTableColumns.UUID));
            serviceProvider.setApplicationName(rs.getString(ApplicationTableColumns.APP_NAME));
            serviceProvider.setDescription(rs.getString(ApplicationTableColumns.DESCRIPTION));
            serviceProvider.setImageUrl(rs.getString(ApplicationTableColumns.IMAGE_URL));
            serviceProvider.setAccessUrl(rs.getString(ApplicationTableColumns.ACCESS_URL));
            serviceProvider.setDiscoverable(getBooleanValue(rs.getString(ApplicationTableColumns.IS_DISCOVERABLE)));
            User owner = new User();
            owner.setUserName(rs.getString(ApplicationTableColumns.USERNAME));
            owner.setUserStoreDomain(rs.getString(ApplicationTableColumns.USER_STORE));
            owner.setTenantDomain(IdentityTenantUtil.getTenantDomain(rs.getInt(ApplicationTableColumns.TENANT_ID)));
            serviceProvider.setOwner(owner);
            ClaimConfig claimConfig = new ClaimConfig();
            claimConfig.setRoleClaimURI(rs.getString(ApplicationTableColumns.ROLE_CLAIM));
            claimConfig.setLocalClaimDialect(getBooleanValue(rs.getString(ApplicationTableColumns.IS_LOCAL_CLAIM_DIALECT)));
            claimConfig.setAlwaysSendMappedLocalSubjectId(getBooleanValue(rs.getString(ApplicationTableColumns.IS_SEND_LOCAL_SUBJECT_ID)));
            serviceProvider.setClaimConfig(claimConfig);
            LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
            localAndOutboundAuthenticationConfig.setAlwaysSendBackAuthenticatedListOfIdPs(getBooleanValue(rs.getString(ApplicationTableColumns.IS_SEND_AUTH_LIST_OF_IDPS)));
            localAndOutboundAuthenticationConfig.setEnableAuthorization(getBooleanValue(rs.getString(ApplicationTableColumns.ENABLE_AUTHORIZATION)));
            localAndOutboundAuthenticationConfig.setSubjectClaimUri(rs.getString(ApplicationTableColumns.SUBJECT_CLAIM_URI));
            serviceProvider.setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
            serviceProvider.setSaasApp(getBooleanValue(rs.getString(ApplicationTableColumns.IS_SAAS_APP)));
            if (log.isDebugEnabled()) {
                log.debug("ApplicationID: " + serviceProvider.getApplicationID() + " ApplicationName: " + serviceProvider.getApplicationName() + " UserName: " + serviceProvider.getOwner().getUserName() + " TenantDomain: " + serviceProvider.getOwner().getTenantDomain());
            }
        }
        return serviceProvider;
    } finally {
        IdentityApplicationManagementUtil.closeResultSet(rs);
        IdentityApplicationManagementUtil.closeStatement(prepStmt);
    }
}
Also used : User(org.wso2.carbon.identity.application.common.model.User) LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) NamedPreparedStatement(org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)

Example 27 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class ApplicationDAOImpl method readAndSetConfigurationsFromProperties.

private void readAndSetConfigurationsFromProperties(List<ServiceProviderProperty> propertyList, LocalAndOutboundAuthenticationConfig localAndOutboundConfig) {
    // Override with changed values.
    if (CollectionUtils.isNotEmpty(propertyList)) {
        for (ServiceProviderProperty serviceProviderProperty : propertyList) {
            String name = serviceProviderProperty.getName();
            String value = serviceProviderProperty.getValue();
            if (USE_DOMAIN_IN_ROLES.equals(name)) {
                localAndOutboundConfig.setUseUserstoreDomainInRoles(value == null || Boolean.parseBoolean(value));
            } else if (SKIP_CONSENT.equals(name)) {
                localAndOutboundConfig.setSkipConsent(Boolean.parseBoolean(value));
            } else if (SKIP_LOGOUT_CONSENT.equals(name)) {
                localAndOutboundConfig.setSkipLogoutConsent(Boolean.parseBoolean(value));
            }
        }
    }
}
Also used : ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)

Example 28 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class UIBasedConfigurationLoaderTest method testGetSequence_Deprecated.

public void testGetSequence_Deprecated() throws Exception {
    ServiceProvider testSp1 = new ServiceProvider();
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
    testSp1.setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
    AuthenticationStep step1 = new AuthenticationStep();
    step1.setStepOrder(1);
    AuthenticationStep step2 = new AuthenticationStep();
    step1.setStepOrder(2);
    AuthenticationStep[] authenticationSteps = new AuthenticationStep[] { step1, step2 };
    localAndOutboundAuthenticationConfig.setAuthenticationSteps(authenticationSteps);
    SequenceConfig sequenceConfig = loader.getSequence(testSp1, "test_domain");
    assertNotNull(sequenceConfig);
    assertNotNull(sequenceConfig.getStepMap());
    assertNotNull(sequenceConfig.getStepMap().get(1));
    assertNotNull(sequenceConfig.getStepMap().get(2));
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)

Example 29 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class DefaultAuthenticationRequestHandlerTest method testHandleRememberMeOptionFromLoginPage.

@Test(dataProvider = "rememberMeParamProvider")
public void testHandleRememberMeOptionFromLoginPage(String rememberMeParam, boolean expectedResult) throws Exception {
    doReturn(rememberMeParam).when(request).getParameter(FrameworkConstants.RequestParams.REMEMBER_ME);
    AuthenticationContext context = spy(new AuthenticationContext());
    SequenceConfig sequenceConfig = spy(new SequenceConfig());
    when(sequenceConfig.isCompleted()).thenReturn(true);
    ServiceProvider serviceProvider = spy(new ServiceProvider());
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = spy(new LocalAndOutboundAuthenticationConfig());
    when(localAndOutboundAuthenticationConfig.getAuthenticationType()).thenReturn(ApplicationConstants.AUTH_TYPE_LOCAL);
    serviceProvider.setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
    ApplicationConfig applicationConfig = spy(new ApplicationConfig(serviceProvider));
    sequenceConfig.setApplicationConfig(applicationConfig);
    context.setSequenceConfig(sequenceConfig);
    // mock the context to show that flow is returning back from login page
    when(context.isReturning()).thenReturn(true);
    when(context.getCurrentStep()).thenReturn(0);
    DefaultAuthenticationRequestHandler authenticationRequestHandler = spy(new DefaultAuthenticationRequestHandler());
    // mock session nonce cookie validation
    mockStatic(SessionNonceCookieUtil.class);
    when(SessionNonceCookieUtil.validateNonceCookie(any(), any())).thenReturn(true);
    // Mock conclude flow and post authentication flows to isolate remember me option
    doNothing().when(authenticationRequestHandler).concludeFlow(request, response, context);
    authenticationRequestHandler.handle(request, response, context);
    assertEquals(context.isRememberMe(), expectedResult);
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) 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) Test(org.testng.annotations.Test) PostAuthenticationMgtServiceTest(org.wso2.carbon.identity.application.authentication.framework.services.PostAuthenticationMgtServiceTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 30 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig 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)

Aggregations

LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)24 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig)13 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)12 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)8 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)7 AuthenticationStep (org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)7 PreparedStatement (java.sql.PreparedStatement)6 ArrayList (java.util.ArrayList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 Test (org.testng.annotations.Test)6 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)6 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig)6 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)5 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)5 ResultSet (java.sql.ResultSet)4 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)4 User (org.wso2.carbon.identity.application.common.model.User)4 InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig)4 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)4 ApplicationConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig)3