Examples of DefaultPolicy


Examples of org.apache.harmony.security.fortress.DefaultPolicy

    public void testRefresh() {
        Permission sp = new SecurityPermission("sdf");
        PolicyEntry[] pe = new PolicyEntry[] { new PolicyEntry(null, null,
            Arrays.asList(new Permission[] { sp })) };
        TestParser tp = new TestParser(pe);
        DefaultPolicy policy = new DefaultPolicy(tp);
        CodeSource cs = new CodeSource(null, (Certificate[])null);
        assertTrue(policy.getPermissions(cs).implies(sp));

        tp.content = new PolicyEntry[0];
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));

        tp.content = null;
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));
    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

    /**
     * Tests that refresh() does not fail on failing parser.
     */
    public void testRefresh_Failure() {
        CodeSource cs = new CodeSource(null, (Certificate[])null);
        DefaultPolicy policy = new DefaultPolicy(new TestParser(null));
        policy.refresh();
        assertFalse(policy.getPermissions(cs).elements().hasMoreElements());
    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

        PolicyEntry pe3 = new PolicyEntry(cs, Arrays
            .asList(new Principal[] { new FakePrincipal("qqq") }), Arrays
            .asList(new Permission[] { sp3 }));
        PolicyEntry[] peArray = new PolicyEntry[] {
            pe1, pe2, pe3 };
        DefaultPolicy policy = new DefaultPolicy(new TestParser(peArray));

        assertTrue(policy.getPermissions(cs).implies(sp1));
        assertFalse(policy.getPermissions(cs).implies(sp2));
        assertFalse(policy.getPermissions(cs).implies(sp3));

        assertTrue(policy.getPermissions(cs2).implies(sp1));
        assertTrue(policy.getPermissions(cs2).implies(sp2));
        assertFalse(policy.getPermissions(cs2).implies(sp3));
    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

            .asList(new Principal[] { new UnresolvedPrincipal(
                FakePrincipal.class.getName(), "ttt") }), Arrays
            .asList(new Permission[] { sp4 }));
        PolicyEntry[] peArray = new PolicyEntry[] {
            pe1, pe2, pe3, pe4 };
        DefaultPolicy policy = new DefaultPolicy(new TestParser(peArray));

        assertTrue(policy.getPermissions(pd1).implies(sp1));
        assertFalse(policy.getPermissions(pd1).implies(sp2));
        assertFalse(policy.getPermissions(pd1).implies(sp3));
        assertFalse(policy.getPermissions(pd1).implies(sp4));

        assertTrue(policy.getPermissions(pd2).implies(sp1));
        assertTrue(policy.getPermissions(pd2).implies(sp2));
        assertTrue(policy.getPermissions(pd2).implies(sp3));
        assertFalse(policy.getPermissions(pd2).implies(sp4));
    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

                        POLICY_PROVIDER));
        if (defaultClass == null) {
            //TODO log warning
            //System.err.println("No policy provider specified. Loading the "
            //           + DefaultPolicy.class.getName());
            return new DefaultPolicy();
        }

        // TODO accurate classloading
        return AccessController.doPrivileged(new PrivilegedAction<Policy>() {

            public Policy run() {
                try {
                    return (Policy) Class.forName(defaultClass, true,
                            ClassLoader.getSystemClassLoader()).newInstance();
                }
                catch (Exception e) {
                    //TODO log error
                    //System.err.println("Error loading policy provider <"
                    //                 + defaultClass + "> : " + e
                    //                 + "\nSwitching to the default "
                    //                 + DefaultPolicy.class.getName());
                    return new DefaultPolicy();
                }
            }
        });

    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

            POLICY_PROVIDER));
    if (defaultClass == null) {
      // TODO log warning
      // System.err.println("No policy provider specified. Loading the "
      // + DefaultPolicy.class.getName());
      return new DefaultPolicy();
    }

        // TODO accurate classloading
        return AccessController.doPrivileged(new PrivilegedAction<Policy>() {

            public Policy run() {
                try {
                    return (Policy) Class.forName(defaultClass, true,
                            ClassLoader.getSystemClassLoader()).newInstance();
                }
                catch (Exception e) {
                    //TODO log error
                    //System.err.println("Error loading policy provider <"
                    //                 + defaultClass + "> : " + e
                    //                 + "\nSwitching to the default "
                    //                 + DefaultPolicy.class.getName());
                    return new DefaultPolicy();
                }
            }
        });

    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

  private DefaultPolicy defaultPolicy = null;
 
  private URIParameter para = null;

  public PolicySpiImpl() {
    defaultPolicy = new DefaultPolicy(false);
    engineRefreshImpl();
  }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

    defaultPolicy = new DefaultPolicy(false);
    engineRefreshImpl();
  }
 
  public PolicySpiImpl(URIParameter params) {
    defaultPolicy = new DefaultPolicy(false);
    para = params;
    engineRefreshImpl();
  }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

                        POLICY_PROVIDER));
        if (defaultClass == null) {
            //TODO log warning
            //System.err.println("No policy provider specified. Loading the "
            //           + DefaultPolicy.class.getName());
            return new DefaultPolicy();
        }

        // TODO accurate classloading
        return AccessController.doPrivileged(new PrivilegedAction<Policy>() {

            public Policy run() {
                try {
                    return (Policy) Class.forName(defaultClass, true,
                            ClassLoader.getSystemClassLoader()).newInstance();
                }
                catch (Exception e) {
                    //TODO log error
                    //System.err.println("Error loading policy provider <"
                    //                 + defaultClass + "> : " + e
                    //                 + "\nSwitching to the default "
                    //                 + DefaultPolicy.class.getName());
                    return new DefaultPolicy();
                }
            }
        });

    }
View Full Code Here

Examples of org.apache.harmony.security.fortress.DefaultPolicy

    public void testRefresh() {
        Permission sp = new SecurityPermission("sdf");
        PolicyEntry[] pe = new PolicyEntry[] { new PolicyEntry(null, null,
            Arrays.asList(new Permission[] { sp })) };
        TestParser tp = new TestParser(pe);
        DefaultPolicy policy = new DefaultPolicy(tp);
        CodeSource cs = new CodeSource(null, (Certificate[])null);
        assertTrue(policy.getPermissions(cs).implies(sp));

        tp.content = new PolicyEntry[0];
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));

        tp.content = null;
        policy.refresh();
        assertFalse(policy.getPermissions(cs).implies(sp));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.