Search in sources :

Example 41 with ServiceProvider

use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method deleteApplication.

public void deleteApplication(String applicationName) throws IdentityApplicationManagementException {
    String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    ServiceProvider serviceProvider = getApplication(applicationName, tenantDomain);
    clearAllAppCache(serviceProvider, tenantDomain);
    appDAO.deleteApplication(applicationName);
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider)

Example 42 with ServiceProvider

use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method updateApplicationByResourceId.

@Override
public void updateApplicationByResourceId(String resourceId, String tenantDomain, ServiceProvider updatedApp) throws IdentityApplicationManagementException {
    ServiceProvider storedApp = getApplicationByResourceId(resourceId, tenantDomain);
    clearAllAppCache(storedApp, tenantDomain);
    appDAO.updateApplicationByResourceId(resourceId, tenantDomain, updatedApp);
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider)

Example 43 with ServiceProvider

use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method getApplication.

public ServiceProvider getApplication(int appId) throws IdentityApplicationManagementException {
    ServiceProvider serviceProvider = getApplicationFromCache(appId, CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
    if (serviceProvider == null) {
        serviceProvider = appDAO.getApplication(appId);
        if (serviceProvider == null) {
            throw new IdentityApplicationManagementException("Error while getting the service provider for appId: " + appId);
        }
        addToCache(serviceProvider, serviceProvider.getOwner().getTenantDomain());
    }
    return serviceProvider;
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)

Example 44 with ServiceProvider

use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method clearAppCacheByInboundKey.

private static void clearAppCacheByInboundKey(ServiceProvider serviceProvider, String tenantDomain) {
    if (serviceProvider.getInboundAuthenticationConfig() != null && serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs() != null) {
        InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
        for (InboundAuthenticationRequestConfig config : configs) {
            if (config.getInboundAuthKey() != null) {
                ServiceProviderCacheInboundAuthKey clientKey = new ServiceProviderCacheInboundAuthKey(config.getInboundAuthKey(), config.getInboundAuthType());
                appCacheByInboundAuth.clearCacheEntry(clientKey, tenantDomain);
            }
        }
    }
}
Also used : ServiceProviderCacheInboundAuthKey(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)

Example 45 with ServiceProvider

use of org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method addToCache.

private void addToCache(ServiceProvider serviceProvider, String tenantDomain) {
    if (log.isDebugEnabled()) {
        log.debug("Add cache for the application " + serviceProvider.getApplicationName() + "@" + tenantDomain);
    }
    IdentityServiceProviderCacheKey nameKey = new IdentityServiceProviderCacheKey(serviceProvider.getApplicationName());
    IdentityServiceProviderCacheEntry nameEntry = new IdentityServiceProviderCacheEntry(serviceProvider);
    appCacheByName.addToCache(nameKey, nameEntry, tenantDomain);
    ServiceProviderIDCacheKey idKey = new ServiceProviderIDCacheKey(serviceProvider.getApplicationID());
    ServiceProviderIDCacheEntry idEntry = new ServiceProviderIDCacheEntry(serviceProvider);
    appCacheByID.addToCache(idKey, idEntry, tenantDomain);
    ServiceProviderResourceIdCacheKey resourceIdCacheKey = new ServiceProviderResourceIdCacheKey(serviceProvider.getApplicationResourceId());
    ServiceProviderResourceIdCacheEntry entry = new ServiceProviderResourceIdCacheEntry(serviceProvider);
    appCacheByResourceId.addToCache(resourceIdCacheKey, entry, tenantDomain);
    if (serviceProvider.getInboundAuthenticationConfig() != null && serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs() != null) {
        InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
        for (InboundAuthenticationRequestConfig config : configs) {
            if (config.getInboundAuthKey() != null) {
                ServiceProviderCacheInboundAuthKey clientKey = new ServiceProviderCacheInboundAuthKey(config.getInboundAuthKey(), config.getInboundAuthType());
                ServiceProviderCacheInboundAuthEntry clientEntry = new ServiceProviderCacheInboundAuthEntry(serviceProvider.getApplicationName(), tenantDomain);
                appCacheByInboundAuth.addToCache(clientKey, clientEntry, tenantDomain);
            }
        }
    }
}
Also used : ServiceProviderIDCacheKey(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderIDCacheKey) ServiceProviderCacheInboundAuthEntry(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthEntry) ServiceProviderCacheInboundAuthKey(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey) ServiceProviderResourceIdCacheKey(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderResourceIdCacheKey) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig) IdentityServiceProviderCacheEntry(org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheEntry) ServiceProviderIDCacheEntry(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderIDCacheEntry) ServiceProviderResourceIdCacheEntry(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderResourceIdCacheEntry) IdentityServiceProviderCacheKey(org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey)

Aggregations

ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)222 Test (org.testng.annotations.Test)120 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)96 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)85 ArrayList (java.util.ArrayList)65 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)58 HashMap (java.util.HashMap)50 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)49 ApplicationManagementService (org.wso2.carbon.identity.application.mgt.ApplicationManagementService)40 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)35 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)33 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)29 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)26 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)25 IdentityException (org.wso2.carbon.identity.base.IdentityException)23 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)21 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)20 InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig)20 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)20 Matchers.anyString (org.mockito.Matchers.anyString)19