Search in sources :

Example 1 with PIPAttributeFinder

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();
        }
    }
}
Also used : CarbonAttributeFinder(org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder) PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) Properties(java.util.Properties)

Example 2 with PIPAttributeFinder

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;
            }
        }
    }
}
Also used : CarbonAttributeFinder(org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder) PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) Properties(java.util.Properties) Map(java.util.Map)

Example 3 with PIPAttributeFinder

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;
}
Also used : PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) PIPFinderDataHolder(org.wso2.carbon.identity.entitlement.dto.PIPFinderDataHolder) Properties(java.util.Properties) Map(java.util.Map)

Example 4 with PIPAttributeFinder

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();
            }
        }
    }
}
Also used : CarbonAttributeFinder(org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder) PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) Properties(java.util.Properties)

Example 5 with PIPAttributeFinder

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);
    }
}
Also used : PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)8 PIPAttributeFinder (org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder)7 AbstractPIPAttributeFinder (org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder)5 CarbonAttributeFinder (org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 URISyntaxException (java.net.URISyntaxException)2 ParseException (java.text.ParseException)2 Iterator (java.util.Iterator)2 TransformerException (javax.xml.transform.TransformerException)2 ParsingException (org.wso2.balana.ParsingException)2 AttributeValue (org.wso2.balana.attr.AttributeValue)1 BagAttribute (org.wso2.balana.attr.BagAttribute)1 EvaluationResult (org.wso2.balana.cond.EvaluationResult)1 Status (org.wso2.balana.ctx.Status)1 PIPAttributeCache (org.wso2.carbon.identity.entitlement.cache.PIPAttributeCache)1 PDPDataHolder (org.wso2.carbon.identity.entitlement.dto.PDPDataHolder)1 PIPFinderDataHolder (org.wso2.carbon.identity.entitlement.dto.PIPFinderDataHolder)1 PIPResourceFinder (org.wso2.carbon.identity.entitlement.pip.PIPResourceFinder)1 PolicyFinderModule (org.wso2.carbon.identity.entitlement.policy.finder.PolicyFinderModule)1