use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getLocalIdPToServiceProviderClaimMapping.
/**
* [local-idp-claim-uri,sp-claim-uri]
*
* @param serviceProviderName
* @param tenantDomain
* @return
* @throws IdentityApplicationManagementException
*/
@Override
public Map<String, String> getLocalIdPToServiceProviderClaimMapping(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
Map<String, String> claimMap = appDAO.getLocalIdPToServiceProviderClaimMapping(serviceProviderName, tenantDomain);
if (claimMap == null || claimMap.isEmpty() && ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(serviceProviderName)) {
return new FileBasedApplicationDAO().getLocalIdPToServiceProviderClaimMapping(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 getApplicationBasicInfoByName.
@Override
public ApplicationBasicInfo getApplicationBasicInfoByName(String name, String tenantDomain) throws IdentityApplicationManagementException {
Collection<ApplicationResourceManagementListener> listeners = ApplicationMgtListenerServiceComponent.getApplicationResourceMgtListeners();
for (ApplicationResourceManagementListener listener : listeners) {
if (listener.isEnabled() && !listener.doPreGetApplicationBasicInfoByName(name, tenantDomain)) {
throw buildServerException("Error executing doPreGetApplicationBasicInfoByName operation of " + "listener: " + getName(listener) + " for application name: " + name);
}
}
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
ApplicationBasicInfo basicAppInfo = appDAO.getApplicationBasicInfoByName(name, tenantDomain);
for (ApplicationResourceManagementListener listener : listeners) {
if (listener.isEnabled() && !listener.doPostGetApplicationBasicInfoByName(basicAppInfo, name, tenantDomain)) {
throw buildServerException("Error executing doPostGetApplicationBasicInfoByName operation of " + "listener: " + getName(listener) + " for application name: " + name);
}
}
return basicAppInfo;
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationMgtSystemConfig method getApplicationDAO.
/**
* Return an instance of the ApplicationDAO
*
* @return
*/
public ApplicationDAO getApplicationDAO() {
ApplicationDAO applicationDAO = null;
if (appDAOClassName != null) {
try {
// Bundle class loader will cache the loaded class and returned
// the already loaded instance, hence calling this method
// multiple times doesn't cost.
Class clazz = Class.forName(appDAOClassName);
applicationDAO = (ApplicationDAO) clazz.newInstance();
} catch (ClassNotFoundException e) {
log.error("Error while instantiating the ApplicationDAO ", e);
} catch (InstantiationException e) {
log.error("Error while instantiating the ApplicationDAO ", e);
} catch (IllegalAccessException e) {
log.error("Error while instantiating the ApplicationDAO ", e);
}
} else {
applicationDAO = new ApplicationDAOImpl();
}
return new CacheBackedApplicationDAO(applicationDAO);
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationMgtUtil method isUserAuthorized.
public static boolean isUserAuthorized(String applicationName, String username, int applicationID) throws IdentityApplicationManagementException {
if (!isUserAuthorized(applicationName, username)) {
// maybe the role name of the app has updated. In this case, lets
// load back the old app name
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
String storedApplicationName = appDAO.getApplicationName(applicationID);
return isUserAuthorized(storedApplicationName, username);
}
return true;
}
use of org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method createApplicationWithTemplate.
@Override
public ServiceProvider createApplicationWithTemplate(ServiceProvider serviceProvider, String tenantDomain, String username, String templateName) throws IdentityApplicationManagementException {
// Call pre listeners.
Collection<ApplicationMgtListener> listeners = getApplicationMgtListeners();
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPreCreateApplication(serviceProvider, tenantDomain, username)) {
throw buildServerException("Pre create application operation of listener: " + getName(listener) + " failed for application: " + serviceProvider.getApplicationName() + " of tenantDomain: " + tenantDomain);
}
}
doPreAddApplicationChecks(serviceProvider, tenantDomain, username);
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
serviceProvider.setOwner(getUser(tenantDomain, username));
int appId = doAddApplication(serviceProvider, tenantDomain, username, appDAO::createApplication);
serviceProvider.setApplicationID(appId);
setDisplayNamesOfLocalAuthenticators(serviceProvider, tenantDomain);
SpTemplate spTemplate = this.getApplicationTemplate(templateName, tenantDomain);
if (spTemplate != null) {
updateSpFromTemplate(serviceProvider, tenantDomain, spTemplate);
appDAO.updateApplication(serviceProvider, tenantDomain);
}
for (ApplicationMgtListener listener : listeners) {
if (listener.isEnable() && !listener.doPostCreateApplication(serviceProvider, tenantDomain, username)) {
log.error("Post create application operation of listener:" + getName(listener) + " failed for " + "application: " + serviceProvider.getApplicationName() + " of tenantDomain: " + tenantDomain);
break;
}
}
triggerAuditLogEvent(getInitiatorId(username, tenantDomain), getInitiatorId(username, tenantDomain), USER, CarbonConstants.LogEventConstants.EventCatalog.CREATE_APPLICATION.getEventId(), getAppId(serviceProvider), getApplicationName(serviceProvider), TARGET_APPLICATION, buildSPData(serviceProvider));
return serviceProvider;
}
Aggregations