Search in sources :

Example 71 with IdentityProvider

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

Example 72 with IdentityProvider

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);
}
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 73 with IdentityProvider

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);
    }
}
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 74 with IdentityProvider

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);
}
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 75 with IdentityProvider

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

Aggregations

IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)191 Test (org.testng.annotations.Test)103 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)65 ArrayList (java.util.ArrayList)64 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)54 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)53 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)47 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)47 API (org.wso2.carbon.apimgt.core.models.API)43 IdentityProvider (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider)37 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)35 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)34 Property (org.wso2.carbon.identity.application.common.model.Property)29 FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig)29 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)27 Connection (java.sql.Connection)25 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)22 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)22 HashMap (java.util.HashMap)20 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)20