org.wso2.balana.finder.ResourceFinder Java Examples

The following examples show how to use org.wso2.balana.finder.ResourceFinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Main.java    From balana with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(){

    PDPConfig pdpConfig = balana.getPdpConfig();

    // registering new attribute finder. so default PDPConfig is needed to change
    AttributeFinder attributeFinder = pdpConfig.getAttributeFinder();
    List<AttributeFinderModule> finderModules = attributeFinder.getModules();
    finderModules.add(new SampleAttributeFinderModule());
    attributeFinder.setModules(finderModules);

    // registering new resource finder. so default PDPConfig is needed to change
    ResourceFinder resourceFinder = pdpConfig.getResourceFinder();
    List<ResourceFinderModule> resourceModules = resourceFinder.getModules();
    resourceModules.add(new HierarchicalResourceFinder());
    resourceFinder.setModules(resourceModules);


    return new PDP(new PDPConfig(attributeFinder, pdpConfig.getPolicyFinder(), resourceFinder, true));
}
 
Example #2
Source File: PDPConfig.java    From balana with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor that creates a <code>PDPConfig</code> from components.
 * 
 * @param attributeFinder the <code>AttributeFinder</code> that the PDP should use, or null if
 *            it shouldn't use any
 * @param policyFinder the <code>PolicyFinder</code> that the PDP should use, or null if it
 *            shouldn't use any
 * @param resourceFinder the <code>ResourceFinder</code> that the PDP should use, or null if it
 *            shouldn't use any
 * @param multipleRequestHandle whether PDP capable of handling multiple requests or not
 */
public PDPConfig(AttributeFinder attributeFinder, PolicyFinder policyFinder,
        ResourceFinder resourceFinder, boolean multipleRequestHandle) {
    if (attributeFinder != null)
        this.attributeFinder = attributeFinder;
    else
        this.attributeFinder = new AttributeFinder();

    if (policyFinder != null)
        this.policyFinder = policyFinder;
    else
        this.policyFinder = new PolicyFinder();

    if (resourceFinder != null)
        this.resourceFinder = resourceFinder;
    else
        this.resourceFinder = new ResourceFinder();

    this.multipleRequestHandle = multipleRequestHandle;
}
 
Example #3
Source File: ConfigurationStore.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Private helper that handles the pdp elements.
 */
private PDPConfig parsePDPConfig(Node root) throws ParsingException {
    ArrayList attrModules = new ArrayList();
    HashSet policyModules = new HashSet();
    ArrayList rsrcModules = new ArrayList();

    // go through all elements of the pdp, loading the specified modules
    NodeList children = root.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        String name = DOMHelper.getLocalName(child);

        if (name.equals("policyFinderModule")) {
            policyModules.add(loadClass("module", child));
        } else if (name.equals("attributeFinderModule")) {
            attrModules.add(loadClass("module", child));
        } else if (name.equals("resourceFinderModule")) {
            rsrcModules.add(loadClass("module", child));
        }
    }

    // after loading the modules, use the collections to setup a
    // PDPConfig based on this pdp element

    AttributeFinder attrFinder = new AttributeFinder();
    attrFinder.setModules(attrModules);

    PolicyFinder policyFinder = new PolicyFinder();
    policyFinder.setModules(policyModules);

    ResourceFinder rsrcFinder = new ResourceFinder();
    rsrcFinder.setModules(rsrcModules);

    return new PDPConfig(attrFinder, policyFinder, rsrcFinder);
}
 
Example #4
Source File: PDPConfig.java    From balana with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor that creates a <code>PDPConfig</code> from components.
 *
 * @param attributeFinder the <code>AttributeFinder</code> that the PDP should use, or null if
 *            it shouldn't use any
 * @param policyFinder the <code>PolicyFinder</code> that the PDP should use, or null if it
 *            shouldn't use any
 * @param resourceFinder the <code>ResourceFinder</code> that the PDP should use, or null if it
 *            shouldn't use any
 */
public PDPConfig(AttributeFinder attributeFinder, PolicyFinder policyFinder,
        ResourceFinder resourceFinder) {
    this(attributeFinder, policyFinder, resourceFinder, true);
}
 
Example #5
Source File: PDPConfig.java    From balana with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the <code>ResourceFinder</code> that was configured, or null if none was configured
 * 
 * @return the <code>ResourceFinder</code> or null
 */
public ResourceFinder getResourceFinder() {
    return resourceFinder;
}