Search in sources :

Example 1 with ProvisioningConnectorCacheEntry

use of org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry in project carbon-identity-framework by wso2.

the class AbstractProvisioningConnectorFactory method getConnector.

/**
 * @param identityProviderName
 * @param provisoningProperties
 * @param tenantDomain
 * @return
 * @throws IdentityProvisioningException
 */
public AbstractOutboundProvisioningConnector getConnector(String identityProviderName, Property[] provisoningProperties, String tenantDomain) throws IdentityProvisioningException {
    ProvisioningConnectorCacheKey cacheKey = new ProvisioningConnectorCacheKey(identityProviderName);
    ProvisioningConnectorCacheEntry entry = ProvisioningConnectorCache.getInstance().getValueFromCache(cacheKey, tenantDomain);
    if (entry != null) {
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cache HIT for " + identityProviderName + " of " + tenantDomain);
        }
        return entry.getProvisioningConnector();
    }
    AbstractOutboundProvisioningConnector connector;
    Property idpName = new Property();
    idpName.setName("identityProviderName");
    idpName.setValue(identityProviderName);
    List<Property> provisioningPropertiesList = new ArrayList<>(Arrays.asList(provisoningProperties));
    provisioningPropertiesList.add(idpName);
    Property[] provisioningProperties = new Property[provisioningPropertiesList.size()];
    provisioningProperties = provisioningPropertiesList.toArray(provisioningProperties);
    connector = buildConnector(provisioningProperties);
    entry = new ProvisioningConnectorCacheEntry();
    entry.setProvisioningConnector(connector);
    ProvisioningConnectorCache.getInstance().addToCache(cacheKey, entry, tenantDomain);
    return connector;
}
Also used : ProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry) ProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheKey) ArrayList(java.util.ArrayList) Property(org.wso2.carbon.identity.application.common.model.Property)

Example 2 with ProvisioningConnectorCacheEntry

use of org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry in project carbon-identity-framework by wso2.

the class ProvisioningIdentityProviderMgtListener method destroyConnector.

/**
 * @param identityProviderName
 * @param tenantDomain
 * @throws IdentityProvisioningException
 */
public void destroyConnector(String identityProviderName, String tenantDomain) throws IdentityProvisioningException {
    ProvisioningConnectorCacheKey cacheKey = new ProvisioningConnectorCacheKey(identityProviderName);
    ProvisioningConnectorCacheEntry entry = ProvisioningConnectorCache.getInstance().getValueFromCache(cacheKey, tenantDomain);
    if (entry != null) {
        ProvisioningConnectorCache.getInstance().clearCacheEntry(cacheKey, tenantDomain);
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cached entry removed for idp " + identityProviderName);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cached entry not found for idp " + identityProviderName);
        }
    }
    int tenantId;
    try {
        RealmService realmService = ProvisioningServiceDataHolder.getInstance().getRealmService();
        tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
    } catch (UserStoreException e) {
        throw new IdentityProvisioningException("Error occurred while retrieving tenant id from tenant domain", e);
    }
    try {
        List<String> serviceProviders = provisioningManagementDAO.getSPNamesOfProvisioningConnectorsByIDP(identityProviderName, tenantId);
        for (String serviceProvider : serviceProviders) {
            ServiceProviderProvisioningConnectorCacheKey key = new ServiceProviderProvisioningConnectorCacheKey(serviceProvider);
            ServiceProviderProvisioningConnectorCacheEntry cacheEntry = ServiceProviderProvisioningConnectorCache.getInstance().getValueFromCache(key, tenantDomain);
            if (cacheEntry != null) {
                ServiceProviderProvisioningConnectorCache.getInstance().clearCacheEntry(key, tenantDomain);
                if (log.isDebugEnabled()) {
                    log.debug("Service Provider '" + serviceProvider + "' Provisioning cached entry removed for idp " + identityProviderName);
                }
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("Service Provider '" + serviceProvider + "' Provisioning cached entry not found for idp " + identityProviderName);
                }
            }
        }
    } catch (IdentityApplicationManagementException e) {
        throw new IdentityProvisioningException("Error occurred while removing cache entry from the " + "service provider provisioning connector cache", e);
    }
}
Also used : ServiceProviderProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheEntry) ProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry) IdentityProvisioningException(org.wso2.carbon.identity.provisioning.IdentityProvisioningException) ServiceProviderProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheKey) ProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheKey) RealmService(org.wso2.carbon.user.core.service.RealmService) ServiceProviderProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheEntry) ServiceProviderProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheKey) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) UserStoreException(org.wso2.carbon.user.api.UserStoreException)

Example 3 with ProvisioningConnectorCacheEntry

use of org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry in project carbon-identity-framework by wso2.

the class AbstractProvisioningConnectorFactory method destroyConnector.

/**
 * @param identityProviderName
 * @param tenantDomain
 * @throws IdentityProvisioningException
 */
public void destroyConnector(String identityProviderName, String tenantDomain) throws IdentityProvisioningException {
    ProvisioningConnectorCacheKey cacheKey = new ProvisioningConnectorCacheKey(identityProviderName);
    ProvisioningConnectorCacheEntry entry = ProvisioningConnectorCache.getInstance().getValueFromCache(cacheKey, tenantDomain);
    if (entry != null) {
        ProvisioningConnectorCache.getInstance().clearCacheEntry(cacheKey, tenantDomain);
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cached entry removed for idp " + identityProviderName + " from the connector " + getConnectorType());
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Provisioning cached entry not found for idp " + identityProviderName + " from the connector " + getConnectorType());
        }
    }
}
Also used : ProvisioningConnectorCacheEntry(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry) ProvisioningConnectorCacheKey(org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheKey)

Aggregations

ProvisioningConnectorCacheEntry (org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheEntry)3 ProvisioningConnectorCacheKey (org.wso2.carbon.identity.provisioning.cache.ProvisioningConnectorCacheKey)3 ArrayList (java.util.ArrayList)1 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)1 Property (org.wso2.carbon.identity.application.common.model.Property)1 IdentityProvisioningException (org.wso2.carbon.identity.provisioning.IdentityProvisioningException)1 ServiceProviderProvisioningConnectorCacheEntry (org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheEntry)1 ServiceProviderProvisioningConnectorCacheKey (org.wso2.carbon.identity.provisioning.cache.ServiceProviderProvisioningConnectorCacheKey)1 UserStoreException (org.wso2.carbon.user.api.UserStoreException)1 RealmService (org.wso2.carbon.user.core.service.RealmService)1