Search in sources :

Example 1 with ServiceProviderCacheInboundAuthKey

use of org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey in project carbon-identity-framework by wso2.

the class CacheBackedApplicationDAO method getServiceProviderNameByClientId.

public String getServiceProviderNameByClientId(String clientId, String type, String tenantDomain) throws IdentityApplicationManagementException {
    if (StringUtils.isEmpty(clientId)) {
        return null;
    }
    String appName = null;
    if (tenantDomain != null) {
        ServiceProviderCacheInboundAuthKey cacheKey = new ServiceProviderCacheInboundAuthKey(clientId, type);
        ServiceProviderCacheInboundAuthEntry entry = appCacheByInboundAuth.getValueFromCache(cacheKey, tenantDomain);
        if (entry != null) {
            appName = entry.getServiceProviderName();
        }
    }
    if (appName == null) {
        if (log.isDebugEnabled()) {
            log.debug("Inbound Auth Key Cache is missing for " + clientId);
        }
        appName = appDAO.getServiceProviderNameByClientId(clientId, type, tenantDomain);
        if (tenantDomain != null) {
            ServiceProviderCacheInboundAuthKey clientKey = new ServiceProviderCacheInboundAuthKey(clientId, type);
            ServiceProviderCacheInboundAuthEntry clientEntry = new ServiceProviderCacheInboundAuthEntry(appName, tenantDomain);
            appCacheByInboundAuth.addToCache(clientKey, clientEntry, tenantDomain);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Inbound Auth Key Cache is present for " + clientId);
        }
    }
    return appName;
}
Also used : ServiceProviderCacheInboundAuthEntry(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthEntry) ServiceProviderCacheInboundAuthKey(org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey)

Example 2 with ServiceProviderCacheInboundAuthKey

use of org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey 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 3 with ServiceProviderCacheInboundAuthKey

use of org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey 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

ServiceProviderCacheInboundAuthKey (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthKey)3 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)2 ServiceProviderCacheInboundAuthEntry (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderCacheInboundAuthEntry)2 IdentityServiceProviderCacheEntry (org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheEntry)1 IdentityServiceProviderCacheKey (org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey)1 ServiceProviderIDCacheEntry (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderIDCacheEntry)1 ServiceProviderIDCacheKey (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderIDCacheKey)1 ServiceProviderResourceIdCacheEntry (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderResourceIdCacheEntry)1 ServiceProviderResourceIdCacheKey (org.wso2.carbon.identity.application.mgt.internal.cache.ServiceProviderResourceIdCacheKey)1