use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getServiceProviderToLocalIdPClaimMapping.
/**
* [sp-claim-uri,local-idp-claim-uri]
*
* @param serviceProviderName
* @param tenantDomain
* @return
* @throws IdentityApplicationManagementException
*/
@Override
public Map<String, String> getServiceProviderToLocalIdPClaimMapping(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
Map<String, String> claimMap = appDAO.getServiceProviderToLocalIdPClaimMapping(serviceProviderName, tenantDomain);
if (claimMap == null || claimMap.isEmpty() && ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(serviceProviderName)) {
return new FileBasedApplicationDAO().getServiceProviderToLocalIdPClaimMapping(serviceProviderName, tenantDomain);
}
return claimMap;
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method deleteApplicationByResourceId.
@Override
public void deleteApplicationByResourceId(String resourceId, String tenantDomain, String username) throws IdentityApplicationManagementException {
// Invoking listeners.
Collection<ApplicationResourceManagementListener> listeners = ApplicationMgtListenerServiceComponent.getApplicationResourceMgtListeners();
for (ApplicationResourceManagementListener listener : listeners) {
if (listener.isEnabled() && !listener.doPreDeleteApplicationByResourceId(resourceId, tenantDomain, username)) {
throw buildServerException("Pre Delete application operation of listener: " + getName(listener) + " failed for application with resourceId: " + resourceId);
}
}
ServiceProvider application;
try {
startTenantFlow(tenantDomain);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
application = appDAO.getApplicationByResourceId(resourceId, tenantDomain);
if (application != null) {
String applicationName = application.getApplicationName();
doPreDeleteChecks(applicationName, tenantDomain, username);
ApplicationMgtUtil.deleteAppRole(applicationName);
ApplicationMgtUtil.deletePermissions(applicationName);
// Delete the app information from SP_APP table.
appDAO.deleteApplicationByResourceId(resourceId, tenantDomain);
} else {
if (log.isDebugEnabled()) {
log.debug("Application cannot be found for resourceId: " + resourceId + " in tenantDomain: " + tenantDomain);
}
return;
}
} catch (Exception e) {
log.error(String.format("Application: %s in tenant: %s might have partially deleted", resourceId, tenantDomain));
throw e;
} finally {
endTenantFlow();
}
for (ApplicationResourceManagementListener listener : listeners) {
if (listener.isEnabled() && !listener.doPostDeleteApplicationByResourceId(application, resourceId, tenantDomain, username)) {
log.error("Post Delete application operation of listener: " + getName(listener) + " failed for " + "application with resourceId: " + resourceId);
return;
}
}
triggerAuditLogEvent(getInitiatorId(username, tenantDomain), getInitiatorId(username, tenantDomain), USER, CarbonConstants.LogEventConstants.EventCatalog.DELETE_APPLICATION.getEventId(), getAppId(application), getApplicationName(application), TARGET_APPLICATION, null);
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getApplicationBasicInfo.
@Override
public ApplicationBasicInfo[] getApplicationBasicInfo(String tenantDomain, String username, String filter) throws IdentityApplicationManagementException {
ApplicationDAO appDAO = null;
// invoking the listeners
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreGetApplicationBasicInfo(tenantDomain, username, filter)) {
return new ApplicationBasicInfo[0];
}
}
try {
startTenantFlow(tenantDomain, username);
appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
} finally {
endTenantFlow();
}
if (!(appDAO instanceof AbstractApplicationDAOImpl)) {
log.error("Get application basic info service is not supported.");
throw new IdentityApplicationManagementException("This service is not supported.");
}
// invoking the listeners
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostGetApplicationBasicInfo(appDAO, tenantDomain, username, filter)) {
return new ApplicationBasicInfo[0];
}
}
return ((AbstractApplicationDAOImpl) appDAO).getApplicationBasicInfo(filter);
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getApplicationExcludingFileBasedSPs.
@Override
public ServiceProvider getApplicationExcludingFileBasedSPs(String applicationName, String tenantDomain) throws IdentityApplicationManagementException {
ServiceProvider serviceProvider;
// invoking the listeners
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreGetApplicationExcludingFileBasedSPs(applicationName, tenantDomain)) {
return null;
}
}
try {
startTenantFlow(tenantDomain);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
serviceProvider = appDAO.getApplication(applicationName, tenantDomain);
} finally {
endTenantFlow();
}
// invoking the listeners
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostGetApplicationExcludingFileBasedSPs(serviceProvider, applicationName, tenantDomain)) {
return null;
}
}
return serviceProvider;
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationMgtUtilTest method testIsUserAuthorized.
@Test(dataProvider = "userAuthorizeDataProvider")
public void testIsUserAuthorized(String applicationName, String userName, String allowRoleValidationProperty, String[] userRoles, int applicationId, Boolean expected) throws UserStoreException, IdentityApplicationManagementException {
validateRole(allowRoleValidationProperty);
mockStatic(ApplicationMgtSystemConfig.class);
ApplicationDAO mockApplicationDAO = mock(ApplicationDAO.class);
ApplicationMgtSystemConfig mockAppMgtSystemConfig = mock(ApplicationMgtSystemConfig.class);
when(ApplicationMgtSystemConfig.getInstance()).thenReturn(mockAppMgtSystemConfig);
when(mockAppMgtSystemConfig.getApplicationDAO()).thenReturn(mockApplicationDAO);
when(mockApplicationDAO.getApplicationName(anyInt())).thenReturn(APPLICATION_NAME);
mockUserStoreManager();
when(mockUserStoreManager.getRoleListOfUser(userName)).thenReturn(userRoles);
assertEquals(ApplicationMgtUtil.isUserAuthorized(applicationName, userName), expected);
assertEquals(ApplicationMgtUtil.isUserAuthorized(applicationName, userName, applicationId), expected);
}
Aggregations