org.wso2.balana.finder.PolicyFinderModule Java Examples

The following examples show how to use org.wso2.balana.finder.PolicyFinderModule. 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: BalanaPDP.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
private org.wso2.balana.PDP getPDP(IRI policyAlgorithm) {
    PDPConfig config = balana.getPdpConfig();

    PolicyFinder policyFinder = new PolicyFinder();
    Set<PolicyFinderModule> policyFinderModules = new HashSet<>();
    policyFinderModules.add(balanaPRP);
    policyFinder.setModules(policyFinderModules);

    AttributeFinder attributeFinder = new AttributeFinder();
    List<AttributeFinderModule> attributeFinderModules = new ArrayList<>(config.getAttributeFinder().getModules());
    pips.forEach(pip -> {
        MobiAttributeFinder mobiAttributeFinder = new MobiAttributeFinder(vf, pip, jaxbContext);
        attributeFinderModules.add(mobiAttributeFinder);
    });
    attributeFinder.setModules(attributeFinderModules);

    PDPConfig newConfig = new PDPConfig(attributeFinder, policyFinder, null, false);
    balanaPRP.setPDPConfig(newConfig);
    balanaPRP.setCombiningAlg(getAlgorithm(policyAlgorithm));
    return new org.wso2.balana.PDP(newConfig);
}
 
Example #2
Source File: EntitlementEngine.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private void setUPPolicyFinder() {

        carbonPolicyFinder = new PolicyFinder();
        Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
        CarbonPolicyFinder tmpCarbonPolicyFinder = new CarbonPolicyFinder();
        policyModules.add(tmpCarbonPolicyFinder);
        carbonPolicyFinder.setModules(policyModules);
        carbonPolicyFinder.init();

    }
 
Example #3
Source File: EntitlementEngine.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void setUPPolicyFinder() {

        carbonPolicyFinder = new PolicyFinder();
        Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
        CarbonPolicyFinder tmpCarbonPolicyFinder = new CarbonPolicyFinder();
        policyModules.add(tmpCarbonPolicyFinder);
        carbonPolicyFinder.setModules(policyModules);
        carbonPolicyFinder.init();

    }
 
Example #4
Source File: AdvanceTestV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}
 
Example #5
Source File: ConformanceTestV2.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), false);
    return new PDP(pdpConfig);

}
 
Example #6
Source File: ConformanceTestV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), false);
    return new PDP(pdpConfig);

}
 
Example #7
Source File: BasicTestV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}
 
Example #8
Source File: TestMultipleRequestV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies Set of XACML policy file names
 * @return a  PDP instance
 */

private static PDP getPDPNewInstance(Set<String> policies) {

    PolicyFinder finder = new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for (String policy : policies) {
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
            //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
            pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}
 
Example #9
Source File: TestFunctionV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}
 
Example #10
Source File: TestXPathV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies Set of XACML policy file names
 * @return a  PDP instance
 */

private static PDP getPDPNewInstance(Set<String> policies) {

    PolicyFinder finder = new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for (String policy : policies) {
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
            //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
            pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}
 
Example #11
Source File: TestAlgorithmsV3.java    From balana with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new PDP instance with new XACML policies
 *
 * @param policies  Set of XACML policy file names
 * @return a  PDP instance
 */
private static PDP getPDPNewInstance(Set<String> policies){

    PolicyFinder finder= new PolicyFinder();
    Set<String> policyLocations = new HashSet<String>();

    for(String policy : policies){
        try {
            String policyPath = (new File(".")).getCanonicalPath() + File.separator +
                    TestConstants.RESOURCE_PATH + File.separator + ROOT_DIRECTORY + File.separator +
                    VERSION_DIRECTORY + File.separator + TestConstants.POLICY_DIRECTORY +
                    File.separator + policy;
            policyLocations.add(policyPath);
        } catch (IOException e) {
           //ignore.
        }
    }

    FileBasedPolicyFinderModule testPolicyFinderModule = new FileBasedPolicyFinderModule(policyLocations);
    Set<PolicyFinderModule> policyModules = new HashSet<PolicyFinderModule>();
    policyModules.add(testPolicyFinderModule);
    finder.setModules(policyModules);

    Balana balana = Balana.getInstance();
    PDPConfig pdpConfig = balana.getPdpConfig();
    pdpConfig = new PDPConfig(pdpConfig.getAttributeFinder(), finder,
                                                        pdpConfig.getResourceFinder(), true);
    return new PDP(pdpConfig);

}