use of org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder in project carbon-identity-framework by wso2.
the class CacheClearingUserOperationListener method clearCarbonAttributeCache.
/**
* this method is responsible for clearing all 3 major caches of entitlement engine
* including PIP_ATTRIBUTE_CACHE , PDP_DECISION_INVALIDATION_CACHE, ENTITLEMENT_POLICY_INVALIDATION_CACHE
*/
private void clearCarbonAttributeCache() {
CarbonAttributeFinder finder = EntitlementEngine.getInstance().getCarbonAttributeFinder();
if (finder != null) {
finder.clearAttributeCache();
// Decision cache is cleared within clearAttributeCache.
} else {
// Return if no finders are found
return;
}
// clearing pip attribute finder caches
Map<PIPAttributeFinder, Properties> designators = EntitlementServiceComponent.getEntitlementConfig().getDesignators();
if (designators != null && !designators.isEmpty()) {
Set<PIPAttributeFinder> pipAttributeFinders = designators.keySet();
for (PIPAttributeFinder pipAttributeFinder : pipAttributeFinders) {
pipAttributeFinder.clearCache();
}
}
}
use of org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder in project carbon-identity-framework by wso2.
the class EntitlementAdminService method refreshAttributeFinder.
/**
* Refreshes the supported Attribute ids of a given attribute finder module
*
* @param attributeFinder Canonical name of the attribute finder class.
* @throws EntitlementException throws if fails to refresh
*/
public void refreshAttributeFinder(String attributeFinder) throws EntitlementException {
Map<PIPAttributeFinder, Properties> designators = EntitlementServiceComponent.getEntitlementConfig().getDesignators();
if (attributeFinder != null && designators != null && !designators.isEmpty()) {
Set<Map.Entry<PIPAttributeFinder, Properties>> pipAttributeFinders = designators.entrySet();
for (Map.Entry<PIPAttributeFinder, Properties> entry : pipAttributeFinders) {
if (attributeFinder.equals(entry.getKey().getClass().getName()) || attributeFinder.equals(entry.getKey().getModuleName())) {
try {
entry.getKey().init(entry.getValue());
entry.getKey().clearCache();
CarbonAttributeFinder carbonAttributeFinder = EntitlementEngine.getInstance().getCarbonAttributeFinder();
carbonAttributeFinder.init();
} catch (Exception e) {
throw new EntitlementException("Error while refreshing attribute finder - " + attributeFinder);
}
break;
}
}
}
}
use of org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder in project carbon-identity-framework by wso2.
the class EntitlementAdminService method getPIPAttributeFinderData.
/**
* @param finder
* @return
*/
public PIPFinderDataHolder getPIPAttributeFinderData(String finder) {
PIPFinderDataHolder holder = null;
// get registered finder modules
Map<PIPAttributeFinder, Properties> attributeModules = EntitlementServiceComponent.getEntitlementConfig().getDesignators();
if (attributeModules == null || finder == null) {
return null;
}
for (Map.Entry<PIPAttributeFinder, Properties> entry : attributeModules.entrySet()) {
PIPAttributeFinder module = entry.getKey();
if (module != null && (finder.equals(module.getModuleName()) || finder.equals(module.getClass().getName()))) {
holder = new PIPFinderDataHolder();
if (module.getModuleName() != null) {
holder.setModuleName(module.getModuleName());
} else {
holder.setModuleName(module.getClass().getName());
}
holder.setClassName(module.getClass().getName());
holder.setSupportedAttributeIds(module.getSupportedAttributes().toArray(new String[module.getSupportedAttributes().size()]));
break;
}
}
return holder;
}
use of org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder in project carbon-identity-framework by wso2.
the class EntitlementAdminService method clearCarbonAttributeCache.
/**
* Clears the carbon attribute cache
*
* @throws EntitlementException throws
*/
public void clearCarbonAttributeCache() throws EntitlementException {
CarbonAttributeFinder finder = EntitlementEngine.getInstance().getCarbonAttributeFinder();
if (finder != null) {
finder.clearAttributeCache();
// we need invalidate decision cache as well.
clearDecisionCache();
} else {
throw new EntitlementException("Can not clear attribute cache - Carbon Attribute Finder " + "is not initialized");
}
Map<PIPAttributeFinder, Properties> designators = EntitlementServiceComponent.getEntitlementConfig().getDesignators();
if (designators != null && !designators.isEmpty()) {
Set<PIPAttributeFinder> pipAttributeFinders = designators.keySet();
for (PIPAttributeFinder pipAttributeFinder : pipAttributeFinders) {
if (pipAttributeFinder instanceof AbstractPIPAttributeFinder) {
pipAttributeFinder.clearCache();
}
}
}
}
use of org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder in project carbon-identity-framework by wso2.
the class EntitlementExtensionBuilder method populateAttributeFinders.
/**
* @param properties
* @param holder
* @throws Exception
*/
private void populateAttributeFinders(Properties properties, EntitlementConfigHolder holder) throws Exception {
int i = 1;
PIPAttributeFinder designator = null;
while (properties.getProperty("PIP.AttributeDesignators.Designator." + i) != null) {
String className = properties.getProperty("PIP.AttributeDesignators.Designator." + i++);
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
designator = (PIPAttributeFinder) clazz.newInstance();
int j = 1;
Properties designatorProps = new Properties();
while (properties.getProperty(className + "." + j) != null) {
String[] props = properties.getProperty(className + "." + j++).split(",");
designatorProps.put(props[0], props[1]);
}
designator.init(designatorProps);
holder.addDesignators(designator, designatorProps);
}
}
Aggregations