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;
}
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);
}
}
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());
}
}
}
Aggregations