use of org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method renameTenantRole.
/**
* @param newRoleName
* @param oldRoleName
* @param tenantId
* @param tenantDomain
* @throws IdentityProviderManagementException
*/
public void renameTenantRole(String newRoleName, String oldRoleName, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
log.debug("Removing all cached Identity Provider entries for tenant Domain " + tenantDomain);
List<IdentityProvider> identityProviders = this.getIdPs(null, tenantId, tenantDomain);
for (IdentityProvider identityProvider : identityProviders) {
String identityProviderName = identityProvider.getIdentityProviderName();
identityProvider = this.getIdPByName(null, identityProvider.getIdentityProviderName(), tenantId, tenantDomain);
// An IDP might get deleted from another process. Hence, identityProvider is nullable.
if (identityProvider == null) {
if (log.isDebugEnabled()) {
log.debug(String.format("Continue the iteration since identity provider %s is not available " + "in cache or database of tenant domain %s", identityProviderName, tenantDomain));
}
continue;
}
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(identityProvider.getIdentityProviderName());
idPCacheByName.clearCacheEntry(idPNameCacheKey, tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.clearCacheEntry(idPHomeRealmIdCacheKey, tenantDomain);
}
}
idPMgtDAO.renameTenantRole(newRoleName, oldRoleName, tenantId, tenantDomain);
}
use of org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method addIdPCache.
/**
* Add new cache entries for IDP against cache keys: name, home-realm-id and resource-id.
*
* @param identityProvider Identity Provider information.
* @param tenantDomain Tenant domain of IDP.
*/
public void addIdPCache(IdentityProvider identityProvider, String tenantDomain) {
if (identityProvider != null) {
if (log.isDebugEnabled()) {
log.debug("Adding new entry for Identity Provider: '" + identityProvider.getIdentityProviderName() + "' to cache.");
}
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(identityProvider.getIdentityProviderName());
idPCacheByName.addToCache(idPNameCacheKey, new IdPCacheEntry(identityProvider), tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.addToCache(idPHomeRealmIdCacheKey, new IdPCacheEntry(identityProvider), tenantDomain);
}
IdPResourceIdCacheKey idPResourceIdCacheKey = new IdPResourceIdCacheKey(identityProvider.getResourceId());
idPCacheByResourceId.addToCache(idPResourceIdCacheKey, new IdPCacheEntry(identityProvider), tenantDomain);
}
}
use of org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method renameTenantClaimURI.
/**
* @param newClaimURI
* @param oldClaimURI
* @param tenantId
* @param tenantDomain
* @throws IdentityProviderManagementException
*/
public void renameTenantClaimURI(String newClaimURI, String oldClaimURI, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
log.debug("Removing all cached Identity Provider entries for tenant Domain " + tenantDomain);
List<IdentityProvider> identityProviders = this.getIdPs(null, tenantId, tenantDomain);
for (IdentityProvider identityProvider : identityProviders) {
identityProvider = this.getIdPByName(null, identityProvider.getIdentityProviderName(), tenantId, tenantDomain);
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(identityProvider.getIdentityProviderName());
idPCacheByName.clearCacheEntry(idPNameCacheKey, tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.clearCacheEntry(idPHomeRealmIdCacheKey, tenantDomain);
}
}
idPMgtDAO.renameTenantRole(newClaimURI, oldClaimURI, tenantId, tenantDomain);
}
use of org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method clearIdpCache.
public void clearIdpCache(String idPName, String resourceId, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
// clearing cache entries related to the IDP.
IdentityProvider identityProvider;
if (StringUtils.isNotBlank(resourceId)) {
identityProvider = this.getIdPByResourceId(resourceId, tenantId, tenantDomain);
} else {
identityProvider = this.getIdPByName(null, idPName, tenantId, tenantDomain);
}
if (identityProvider != null) {
if (log.isDebugEnabled()) {
log.debug("Removing entry for Identity Provider " + idPName + " of tenantDomain:" + tenantDomain + " from cache.");
}
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(idPName);
idPCacheByName.clearCacheEntry(idPNameCacheKey, tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.clearCacheEntry(idPHomeRealmIdCacheKey, tenantDomain);
}
if (StringUtils.isNotBlank(resourceId)) {
IdPResourceIdCacheKey idPResourceIdCacheKey = new IdPResourceIdCacheKey(resourceId);
idPCacheByResourceId.clearCacheEntry(idPResourceIdCacheKey, tenantDomain);
}
String idPIssuerName = getIDPIssuerName(identityProvider);
if (StringUtils.isNotBlank(idPIssuerName)) {
IdPMetadataPropertyCacheKey cacheKey = new IdPMetadataPropertyCacheKey(IdentityApplicationConstants.IDP_ISSUER_NAME, idPIssuerName);
idPCacheByMetadataProperty.clearCacheEntry(cacheKey, tenantDomain);
}
} else {
log.debug("Entry for Identity Provider " + idPName + " not found in cache or DB");
}
}
use of org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method deleteTenantRole.
/**
* @param tenantId
* @param role
* @param tenantDomain
* @throws IdentityProviderManagementException
*/
public void deleteTenantRole(int tenantId, String role, String tenantDomain) throws IdentityProviderManagementException {
log.debug("Removing all cached Identity Provider entries for tenant Domain " + tenantDomain);
List<IdentityProvider> identityProviders = this.getIdPs(null, tenantId, tenantDomain);
for (IdentityProvider identityProvider : identityProviders) {
identityProvider = this.getIdPByName(null, identityProvider.getIdentityProviderName(), tenantId, tenantDomain);
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(identityProvider.getIdentityProviderName());
idPCacheByName.clearCacheEntry(idPNameCacheKey, tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.clearCacheEntry(idPHomeRealmIdCacheKey, tenantDomain);
}
}
idPMgtDAO.deleteTenantRole(tenantId, role, tenantDomain);
}
Aggregations