use of org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey 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);
}
}
}
}
use of org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method deleteApplications.
/**
* Delete Applications by tenant id.
*
* @param tenantId The id of the tenant.
* @throws IdentityApplicationManagementException throws when an error occurs in deleting applications.
*/
@Override
public void deleteApplications(int tenantId) throws IdentityApplicationManagementException {
String tenantDomain = IdentityTenantUtil.getTenantDomain(tenantId);
ApplicationBasicInfo[] applicationBasicInfos = getAllApplicationBasicInfo(tenantDomain, CarbonContext.getThreadLocalCarbonContext().getUsername());
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
appDAO.deleteApplications(tenantId);
// Clear cache entries of each deleted SP.
if (log.isDebugEnabled()) {
log.debug("Clearing the cache entries of all SP applications of the tenant: " + tenantDomain);
}
for (ApplicationBasicInfo applicationBasicInfo : applicationBasicInfos) {
IdentityServiceProviderCache.getInstance().clearCacheEntry(new IdentityServiceProviderCacheKey(applicationBasicInfo.getApplicationName()), tenantDomain);
}
}
use of org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedApplicationDAO method clearAllAppCache.
private void clearAllAppCache(ServiceProvider serviceProvider, String updatedName, String tenantDomain) throws IdentityApplicationManagementException {
IdentityServiceProviderCacheKey cacheKey = new IdentityServiceProviderCacheKey(updatedName);
appCacheByName.clearCacheEntry(cacheKey, tenantDomain);
clearAllAppCache(serviceProvider, tenantDomain);
}
use of org.wso2.carbon.identity.application.mgt.cache.IdentityServiceProviderCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedApplicationDAO method getApplicationFromCache.
private ServiceProvider getApplicationFromCache(String applicationName, String tenantDomain) throws IdentityApplicationManagementException {
ServiceProvider serviceProvider = null;
if (StringUtils.isNotBlank(applicationName)) {
IdentityServiceProviderCacheKey cacheKey = new IdentityServiceProviderCacheKey(applicationName);
IdentityServiceProviderCacheEntry entry = appCacheByName.getValueFromCache(cacheKey, tenantDomain);
if (entry != null) {
serviceProvider = entry.getServiceProvider();
}
} else {
if (log.isDebugEnabled()) {
log.debug("Provided application name is empty");
}
}
if (serviceProvider == null) {
if (log.isDebugEnabled()) {
log.debug("Cache missing for the application " + applicationName + "@" + tenantDomain);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Cache is present for the application " + applicationName + "@" + tenantDomain);
}
}
return serviceProvider;
}
Aggregations