use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method forceDeleteIdPByResourceId.
public void forceDeleteIdPByResourceId(String resourceId, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
if (log.isDebugEnabled()) {
log.debug(String.format("Force deleting IDP with resource ID:%s of tenantDomain:%s started.", resourceId, tenantDomain));
}
// Remove cache entries related to the force deleted idps.
IdentityProvider identityProvider = this.getIdPByResourceId(resourceId, tenantId, tenantDomain);
if (identityProvider != null) {
idPMgtDAO.forceDeleteIdPByResourceId(resourceId, tenantId, tenantDomain);
clearIdpCache(identityProvider.getIdentityProviderName(), resourceId, tenantId, tenantDomain);
} else {
if (log.isDebugEnabled()) {
log.debug(String.format("IDP with resource ID:%s of tenantDomain:%s is not found is cache or DB", resourceId, tenantDomain));
}
}
if (log.isDebugEnabled()) {
log.debug(String.format("Force deleting IDP with resource ID:%s of tenantDomain:%s completed.", resourceId, tenantDomain));
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider 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.identity.application.common.model.idp.xsd.IdentityProvider 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.identity.application.common.model.idp.xsd.IdentityProvider 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.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method getIdPNameByResourceId.
public String getIdPNameByResourceId(String resourceId) throws IdentityProviderManagementException {
IdPResourceIdCacheKey cacheKey = new IdPResourceIdCacheKey(resourceId);
IdPCacheEntry entry = idPCacheByResourceId.getValueFromCache(cacheKey, CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
if (entry != null) {
if (log.isDebugEnabled()) {
log.debug("Cache entry found for Identity Provider with resource ID:" + resourceId);
}
IdentityProvider identityProvider = entry.getIdentityProvider();
return identityProvider.getIdentityProviderName();
}
if (log.isDebugEnabled()) {
log.debug("Cache entry not found for Identity Provider with resource ID: " + resourceId + ". Fetching the name from DB");
}
return idPMgtDAO.getIDPNameByResourceId(resourceId);
}
Aggregations