Search in sources :

Example 1 with IdPHomeRealmIdCacheKey

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);
}
Also used : IdPHomeRealmIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdPNameCacheKey(org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey)

Example 2 with IdPHomeRealmIdCacheKey

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);
    }
}
Also used : IdPCacheEntry(org.wso2.carbon.idp.mgt.cache.IdPCacheEntry) IdPHomeRealmIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey) IdPNameCacheKey(org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey) IdPResourceIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPResourceIdCacheKey)

Example 3 with IdPHomeRealmIdCacheKey

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);
}
Also used : IdPHomeRealmIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdPNameCacheKey(org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey)

Example 4 with IdPHomeRealmIdCacheKey

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");
    }
}
Also used : IdPHomeRealmIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdPNameCacheKey(org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey) IdPResourceIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPResourceIdCacheKey) IdPMetadataPropertyCacheKey(org.wso2.carbon.idp.mgt.cache.IdPMetadataPropertyCacheKey)

Example 5 with IdPHomeRealmIdCacheKey

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);
}
Also used : IdPHomeRealmIdCacheKey(org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdPNameCacheKey(org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey)

Aggregations

IdPHomeRealmIdCacheKey (org.wso2.carbon.idp.mgt.cache.IdPHomeRealmIdCacheKey)10 IdPNameCacheKey (org.wso2.carbon.idp.mgt.cache.IdPNameCacheKey)10 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)9 IdPCacheEntry (org.wso2.carbon.idp.mgt.cache.IdPCacheEntry)5 IdPResourceIdCacheKey (org.wso2.carbon.idp.mgt.cache.IdPResourceIdCacheKey)2 IdPAuthPropertyCacheKey (org.wso2.carbon.idp.mgt.cache.IdPAuthPropertyCacheKey)1 IdPMetadataPropertyCacheKey (org.wso2.carbon.idp.mgt.cache.IdPMetadataPropertyCacheKey)1