use of org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationDAOImpl in project carbon-apimgt by wso2.
the class DAOFactory method getApplicationDAO.
public static ApplicationDAO getApplicationDAO() throws APIMgtDAOException {
ApplicationDAO appDAO = null;
try (Connection connection = DAOUtil.getConnection()) {
String driverName = connection.getMetaData().getDriverName();
if (driverName.contains(MYSQL) || driverName.contains(H2)) {
appDAO = new ApplicationDAOImpl();
} else if (driverName.contains(DB2)) {
} else if (driverName.contains(MS_SQL) || driverName.contains(MICROSOFT)) {
appDAO = new ApplicationDAOImpl();
} else if (driverName.contains(POSTGRE)) {
appDAO = new ApplicationDAOImpl();
} else if (driverName.contains(ORACLE)) {
appDAO = new ApplicationDAOImpl();
} else {
throw new APIMgtDAOException("Unhandled DB driver: " + driverName + " detected", ExceptionCodes.APIM_DAO_EXCEPTION);
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting ApplicationDAO", e);
}
setup();
return appDAO;
}
use of org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationDAOImpl 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.impl.ApplicationDAOImpl in project carbon-identity-framework by wso2.
the class DefaultApplicationValidator method validateInboundAuthKey.
/**
* Validate whether the configured inbound authentication key is already being used by another application.
*
* @param inboundConfig Inbound authentication request configuration.
* @param appId Application ID.
* @param tenantDomain Application tenant domain.
* @throws IdentityApplicationManagementException IdentityApplicationManagementException.
*/
private void validateInboundAuthKey(InboundAuthenticationRequestConfig inboundConfig, int appId, String tenantDomain) throws IdentityApplicationManagementException {
if (inboundConfig == null) {
return;
}
/*
* We need to directly retrieve the application from DB since {@link ServiceProviderByInboundAuthCache} cache
* can have inconsistent applications stored against the <inbound-auth-key, inbound-auth-type, tenant-domain>
* cache key which is not unique.
*/
ApplicationDAO applicationDAO = new ApplicationDAOImpl();
String existingAppName = applicationDAO.getServiceProviderNameByClientId(inboundConfig.getInboundAuthKey(), inboundConfig.getInboundAuthType(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
if (StringUtils.isBlank(existingAppName)) {
if (log.isDebugEnabled()) {
log.debug("Cannot find application name for the inbound auth key: " + inboundConfig.getInboundAuthKey() + " of inbound auth type: " + inboundConfig.getInboundAuthType());
}
return;
}
ServiceProvider existingApp = applicationDAO.getApplication(existingAppName, tenantDomain);
if (existingApp != null && existingApp.getApplicationID() != appId) {
String msg = "Inbound key: '" + inboundConfig.getInboundAuthKey() + "' of inbound auth type: '" + inboundConfig.getInboundAuthType() + "' is already configured for the application :'" + existingApp.getApplicationName() + "'";
/*
* Since this is a conflict scenario, we need to use a different error code. Hence throwing an
* 'IdentityApplicationManagementClientException' here with the correct error code.
*/
throw buildClientException(IdentityApplicationConstants.Error.INBOUND_KEY_ALREADY_EXISTS, msg);
}
}
Aggregations