Java Code Examples for sun.security.provider.PolicyFile#implies()

The following examples show how to use sun.security.provider.PolicyFile#implies() . 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: Comparator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static int doBadTest(PolicyFile policy, int testnum) {

        // this principal is not in policy - should not match any policy grants
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        return testnum;
    }
 
Example 2
Source File: Comparator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static int doBadTest(PolicyFile policy, int testnum) {

        // this principal is not in policy - should not match any policy grants
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        return testnum;
    }
 
Example 3
Source File: Comparator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static int doBadTest(PolicyFile policy, int testnum) {

        // this principal is not in policy - should not match any policy grants
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        return testnum;
    }
 
Example 4
Source File: Comparator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static int doBadTest(PolicyFile policy, int testnum) {

        // this principal is not in policy - should not match any policy grants
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        return testnum;
    }
 
Example 5
Source File: Comparator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static int doBadTest(PolicyFile policy, int testnum) {

        // this principal is not in policy - should not match any policy grants
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, badP);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // this principal is not in policy - should not match any policy grants
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        return testnum;
    }
 
Example 6
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int doComparatorTest(PolicyFile policy, int testnum) {

        // security check against one comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for FOO
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for BAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check should fail against FOOBAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 7
Source File: Comparator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static int doCombinedTest(PolicyFile policy, int testnum) {

        // security check against principal followed by comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against comparator followed by principal should pass
        pd = new ProtectionDomain(cs, null, null, p4);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p4);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p5);
        if (!policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match WORLD grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p5);
        if (policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p6);
        if (!policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match HELLO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p6);
        if (policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 8
Source File: Comparator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static int doPrincipalTest(PolicyFile policy, int testnum) {

        // security check against one principal should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two principals should pass
        pd = new ProtectionDomain(cs, null, null, p2);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p2);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 9
Source File: Comparator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static int doPrincipalTest(PolicyFile policy, int testnum) {

        // security check against one principal should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two principals should pass
        pd = new ProtectionDomain(cs, null, null, p2);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p2);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 10
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int doCombinedTest(PolicyFile policy, int testnum) {

        // security check against principal followed by comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against comparator followed by principal should pass
        pd = new ProtectionDomain(cs, null, null, p4);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p4);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p5);
        if (!policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match WORLD grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p5);
        if (policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p6);
        if (!policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match HELLO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p6);
        if (policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 11
Source File: Comparator.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static int doCombinedTest(PolicyFile policy, int testnum) {

        // security check against principal followed by comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against comparator followed by principal should pass
        pd = new ProtectionDomain(cs, null, null, p4);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p4);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p5);
        if (!policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match WORLD grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p5);
        if (policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p6);
        if (!policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match HELLO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p6);
        if (policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 12
Source File: Comparator.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static int doPrincipalTest(PolicyFile policy, int testnum) {

        // security check against one principal should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two principals should pass
        pd = new ProtectionDomain(cs, null, null, p2);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p2);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 13
Source File: Comparator.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static int doPrincipalTest(PolicyFile policy, int testnum) {

        // security check against one principal should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two principals should pass
        pd = new ProtectionDomain(cs, null, null, p2);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p2);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 14
Source File: Comparator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static int doCombinedTest(PolicyFile policy, int testnum) {

        // security check against principal followed by comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against comparator followed by principal should pass
        pd = new ProtectionDomain(cs, null, null, p4);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p4);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p5);
        if (!policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match WORLD grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p5);
        if (policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p6);
        if (!policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match HELLO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p6);
        if (policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 15
Source File: Comparator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static int doComparatorTest(PolicyFile policy, int testnum) {

        // security check against one comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for FOO
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for BAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check should fail against FOOBAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 16
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int doCombinedTest(PolicyFile policy, int testnum) {

        // security check against principal followed by comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against comparator followed by principal should pass
        pd = new ProtectionDomain(cs, null, null, p4);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p4);
        if (policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p5);
        if (!policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match WORLD grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p5);
        if (policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against principal-principal-comparator should pass
        pd = new ProtectionDomain(cs, null, null, p6);
        if (!policy.implies(pd, WORLD)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match HELLO grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p6);
        if (policy.implies(pd, HELLO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 17
Source File: Comparator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int doComparatorTest(PolicyFile policy, int testnum) {

        // security check against one comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for FOO
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for BAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check should fail against FOOBAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 18
Source File: Comparator.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static int doComparatorTest(PolicyFile policy, int testnum) {

        // security check against one comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for FOO
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for BAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check should fail against FOOBAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 19
Source File: Comparator.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static int doComparatorTest(PolicyFile policy, int testnum) {

        // security check against one comparator should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for FOO
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two comparators should pass for BAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check should fail against FOOBAR
        pd = new ProtectionDomain(cs, null, null, p3);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }
 
Example 20
Source File: Comparator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int doPrincipalTest(PolicyFile policy, int testnum) {

        // security check against one principal should pass
        ProtectionDomain pd = new ProtectionDomain(cs, null, null, p1);
        if (!policy.implies(pd, FOO)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match BAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // security check against two principals should pass
        pd = new ProtectionDomain(cs, null, null, p2);
        if (!policy.implies(pd, BAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p1);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        // should not match FOOBAR grant entry in policy
        pd = new ProtectionDomain(cs, null, null, p2);
        if (policy.implies(pd, FOOBAR)) {
            throw new SecurityException("test." + testnum + " failed");
        }
        testnum++;

        testnum = doBadTest(policy, testnum);

        return testnum;
    }