use of org.wso2.carbon.identity.application.common.model.xsd.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);
}
use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig 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;
}
use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method updateAuthenticationScriptConfiguration.
/**
* Updates the authentication script configuration.
*
* @param applicationId
* @param localAndOutboundAuthConfig
* @param connection
* @param tenantID
* @throws SQLException
*/
private void updateAuthenticationScriptConfiguration(int applicationId, LocalAndOutboundAuthenticationConfig localAndOutboundAuthConfig, Connection connection, int tenantID) throws SQLException {
if (localAndOutboundAuthConfig.getAuthenticationScriptConfig() != null) {
AuthenticationScriptConfig authenticationScriptConfig = localAndOutboundAuthConfig.getAuthenticationScriptConfig();
try (PreparedStatement storeAuthScriptPrepStmt = connection.prepareStatement(STORE_SP_AUTH_SCRIPT)) {
storeAuthScriptPrepStmt.setInt(1, tenantID);
storeAuthScriptPrepStmt.setInt(2, applicationId);
storeAuthScriptPrepStmt.setString(3, authenticationScriptConfig.getLanguage());
setBlobValue(authenticationScriptConfig.getContent(), storeAuthScriptPrepStmt, 4);
storeAuthScriptPrepStmt.setString(5, authenticationScriptConfig.isEnabled() ? "1" : "0");
storeAuthScriptPrepStmt.execute();
} catch (IOException ex) {
log.error("Error occurred while updating authentication script configuration.", ex);
}
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method getBasicApplicationData.
/**
* @param applicationName
* @param connection
* @return
* @throws SQLException
*/
private ServiceProvider getBasicApplicationData(String applicationName, Connection connection, int tenantID) throws SQLException, IdentityApplicationManagementException {
ServiceProvider serviceProvider = null;
if (log.isDebugEnabled()) {
log.debug("Loading Basic Application Data of " + applicationName);
}
PreparedStatement loadBasicAppInfoStmt = null;
ResultSet basicAppDataResultSet = null;
try {
loadBasicAppInfoStmt = connection.prepareStatement(LOAD_BASIC_APP_INFO_BY_APP_NAME);
// SELECT * FROM IDN_APPMGT_APP WHERE APP_NAME = ? AND TENANT_ID = ?
loadBasicAppInfoStmt.setString(1, applicationName);
loadBasicAppInfoStmt.setInt(2, tenantID);
basicAppDataResultSet = loadBasicAppInfoStmt.executeQuery();
if (basicAppDataResultSet.next()) {
serviceProvider = new ServiceProvider();
serviceProvider.setApplicationID(basicAppDataResultSet.getInt(1));
serviceProvider.setApplicationResourceId(basicAppDataResultSet.getString(ApplicationTableColumns.UUID));
serviceProvider.setApplicationName(basicAppDataResultSet.getString(3));
serviceProvider.setDescription(basicAppDataResultSet.getString(6));
serviceProvider.setImageUrl(basicAppDataResultSet.getString(ApplicationTableColumns.IMAGE_URL));
serviceProvider.setAccessUrl(basicAppDataResultSet.getString(ApplicationTableColumns.ACCESS_URL));
serviceProvider.setDiscoverable(getBooleanValue(basicAppDataResultSet.getString(ApplicationTableColumns.IS_DISCOVERABLE)));
String tenantDomain;
try {
tenantDomain = ApplicationManagementServiceComponentHolder.getInstance().getRealmService().getTenantManager().getDomain(basicAppDataResultSet.getInt(2));
} catch (UserStoreException e) {
log.error("Error while reading tenantDomain", e);
throw new IdentityApplicationManagementException("Error while reading tenant " + "domain for application " + applicationName);
}
User owner = new User();
owner.setUserName(basicAppDataResultSet.getString(5));
owner.setTenantDomain(tenantDomain);
owner.setUserStoreDomain(basicAppDataResultSet.getString(4));
serviceProvider.setOwner(owner);
ClaimConfig claimConfig = new ClaimConfig();
claimConfig.setRoleClaimURI(basicAppDataResultSet.getString(7));
claimConfig.setLocalClaimDialect("1".equals(basicAppDataResultSet.getString(10)));
claimConfig.setAlwaysSendMappedLocalSubjectId("1".equals(basicAppDataResultSet.getString(11)));
serviceProvider.setClaimConfig(claimConfig);
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
localAndOutboundAuthenticationConfig.setAlwaysSendBackAuthenticatedListOfIdPs("1".equals(basicAppDataResultSet.getString(14)));
localAndOutboundAuthenticationConfig.setEnableAuthorization("1".equals(basicAppDataResultSet.getString(15)));
localAndOutboundAuthenticationConfig.setSubjectClaimUri(basicAppDataResultSet.getString(16));
serviceProvider.setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
serviceProvider.setSaasApp("1".equals(basicAppDataResultSet.getString(17)));
/*
ConsentConfig consentConfig = new ConsentConfig();
consentConfig.setEnabled("1".equals(basicAppDataResultSet.getString(18)));
serviceProvider.setConsentConfig(consentConfig);
*/
if (log.isDebugEnabled()) {
log.debug("ApplicationID: " + serviceProvider.getApplicationID() + " ApplicationName: " + serviceProvider.getApplicationName() + " UserName: " + serviceProvider.getOwner().getUserName() + " TenantDomain: " + serviceProvider.getOwner().getTenantDomain());
}
}
return serviceProvider;
} finally {
IdentityApplicationManagementUtil.closeResultSet(basicAppDataResultSet);
IdentityApplicationManagementUtil.closeStatement(loadBasicAppInfoStmt);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.
the class ApplicationIdentityProviderMgtListener method doPreUpdateIdP.
@Override
public boolean doPreUpdateIdP(String oldIdPName, IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException {
try {
IdentityServiceProviderCache.getInstance().clear(tenantDomain);
IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
ConnectedAppsResult connectedApplications;
String idpId = identityProviderManager.getIdPByName(oldIdPName, tenantDomain).getResourceId();
if (identityProvider.getResourceId() == null && idpId != null) {
identityProvider.setResourceId(idpId);
}
int offset = 0;
do {
connectedApplications = identityProviderManager.getConnectedApplications(idpId, null, offset, tenantDomain);
List<ServiceProvider> serviceProvidersList = new ArrayList<>();
for (String appResourceId : connectedApplications.getApps()) {
ServiceProvider serviceProvider = ApplicationMgtSystemConfig.getInstance().getApplicationDAO().getApplicationByResourceId(appResourceId, tenantDomain);
serviceProvidersList.add(serviceProvider);
}
for (ServiceProvider serviceProvider : serviceProvidersList) {
LocalAndOutboundAuthenticationConfig localAndOutboundAuthConfig = serviceProvider.getLocalAndOutBoundAuthenticationConfig();
AuthenticationStep[] authSteps = localAndOutboundAuthConfig.getAuthenticationSteps();
OutboundProvisioningConfig outboundProvisioningConfig = serviceProvider.getOutboundProvisioningConfig();
IdentityProvider[] provisioningIdps = outboundProvisioningConfig.getProvisioningIdentityProviders();
// Check whether the identity provider is referred in a service provider
validateIdpDisable(identityProvider, authSteps, provisioningIdps);
// Validating Applications with Federated Authenticators configured.
updateApplicationWithFederatedAuthenticators(identityProvider, tenantDomain, serviceProvider, localAndOutboundAuthConfig, authSteps);
// Validating Applications with Outbound Provisioning Connectors configured.
updateApplicationWithProvisioningConnectors(identityProvider, provisioningIdps);
// Clear application caches if IDP name is updated.
if (!StringUtils.equals(oldIdPName, identityProvider.getIdentityProviderName())) {
CacheBackedApplicationDAO.clearAllAppCache(serviceProvider, tenantDomain);
}
}
offset = connectedApplications.getOffSet() + connectedApplications.getLimit();
} while (connectedApplications.getTotalAppCount() > offset);
} catch (IdentityApplicationManagementException e) {
throw new IdentityProviderManagementException("Error when updating default authenticator of service providers", e);
}
return true;
}
Aggregations