/** Clears attribute cache */ public void clearAttributeCache() { if (attributeFinderCache != null) { attributeFinderCache.clearCache(tenantId); if (log.isDebugEnabled()) { log.debug("Attribute value cache is cleared for tenant " + tenantId); } // clear decision cache EntitlementEngine.getInstance().clearDecisionCache(false); } }
/** * Registers PIP attribute handlers with the PDP against their supported attributes. This PIP * attribute handlers are picked from pip-config.xml file - which should be inside * [CARBON_HOME]\repository\conf. */ public void init() { Map<PIPAttributeFinder, Properties> designators = EntitlementServiceComponent.getEntitlementConfig().getDesignators(); Properties properties = EntitlementServiceComponent.getEntitlementConfig().getEngineProperties(); if ("true".equals(properties.getProperty(PDPConstants.ATTRIBUTE_CACHING))) { attributeFinderCache = PIPAttributeCache.getInstance(); attributeFinderCache.clearCache(tenantId); } // clear decision cache if (designators != null && !designators.isEmpty()) { Set<PIPAttributeFinder> pipAttributeFinders = designators.keySet(); for (Iterator iterator = pipAttributeFinders.iterator(); iterator.hasNext(); ) { PIPAttributeFinder pipAttributeFinder = (PIPAttributeFinder) iterator.next(); Set<String> attrs = pipAttributeFinder.getSupportedAttributes(); if (attrs != null) { for (Iterator attrsIter = attrs.iterator(); attrsIter.hasNext(); ) { String attr = (String) attrsIter.next(); if (attrFinders.containsKey(attr)) { List<PIPAttributeFinder> finders = attrFinders.get(attr); if (!finders.contains(pipAttributeFinder)) { finders.add(pipAttributeFinder); if (log.isDebugEnabled()) { log.debug( String.format( "PIP attribute handler %1$s registered for the supported attribute %2$s", pipAttributeFinder.getClass(), attr)); } } } else { List<PIPAttributeFinder> finders = new ArrayList<PIPAttributeFinder>(); finders.add(pipAttributeFinder); attrFinders.put(attr, finders); if (log.isDebugEnabled()) { log.debug( String.format( "PIP attribute handler %1$s registered for the supported attribute %2$s", pipAttributeFinder.getClass(), attr)); } } } } } } }