Search in sources :

Example 86 with ApplicationDAO

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;
}
Also used : FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO)

Example 87 with ApplicationDAO

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;
}
Also used : ApplicationResourceManagementListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationResourceManagementListener) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO) ApplicationBasicInfo(org.wso2.carbon.identity.application.common.model.ApplicationBasicInfo)

Example 88 with ApplicationDAO

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);
}
Also used : CacheBackedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.CacheBackedApplicationDAO) CacheBackedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.CacheBackedApplicationDAO) SAMLApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.SAMLApplicationDAO) OAuthApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.OAuthApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) SAMLApplicationDAOImpl(org.wso2.carbon.identity.application.mgt.dao.impl.SAMLApplicationDAOImpl) ApplicationDAOImpl(org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationDAOImpl) OAuthApplicationDAOImpl(org.wso2.carbon.identity.application.mgt.dao.impl.OAuthApplicationDAOImpl)

Example 89 with 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;
}
Also used : ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO)

Example 90 with ApplicationDAO

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;
}
Also used : SpTemplate(org.wso2.carbon.identity.application.common.model.SpTemplate) AbstractApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener) ApplicationMgtListener(org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener) PaginatableFilterableApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO) ApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO) FileBasedApplicationDAO(org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO)

Aggregations

ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)62 Test (org.testng.annotations.Test)59 Application (org.wso2.carbon.apimgt.core.models.Application)50 BeforeTest (org.testng.annotations.BeforeTest)33 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)32 ApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.ApplicationDAO)31 PaginatableFilterableApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.PaginatableFilterableApplicationDAO)25 FileBasedApplicationDAO (org.wso2.carbon.identity.application.mgt.dao.impl.FileBasedApplicationDAO)25 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)21 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)18 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)18 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)15 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)15 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)13 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)13 AbstractApplicationMgtListener (org.wso2.carbon.identity.application.mgt.listener.AbstractApplicationMgtListener)13 ApplicationMgtListener (org.wso2.carbon.identity.application.mgt.listener.ApplicationMgtListener)13 API (org.wso2.carbon.apimgt.core.models.API)12 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)11 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)10