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);
}
}
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));
}
}
}
}
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));
}
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);
}
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);
}
Aggregations