Package java.security

Examples of java.security.BasicPermission$BasicPermissionCollection


        assertTrue(dp1.equals(dp1));
        assertFalse(dp1.equals(new DelegationPermission("\"aaa\" \"bbb\"")));
        assertTrue(dp2.equals(dp1));
        assertTrue(dp1.equals(dp2));
        assertTrue(dp1.hashCode() == dp2.hashCode());
        assertFalse(dp1.equals(new BasicPermission("\"AAA\""){}));
    }
View Full Code Here


import java.security.BasicPermission;

public class ExitVMEquals {
    public static void main(String[] args) throws Exception {
        BasicPermission bp1 = new BP("exitVM");
        BasicPermission bp2 = new BP("exitVM.*");

        StringBuffer sb = new StringBuffer();

        // First, make sure the old restrictions on exitVM and exitVM.* still hold.
        if (!bp1.implies(bp2)) sb.append("bp1 does not implies bp2\n");
        if (!bp2.implies(bp1)) sb.append("bp2 does not implies bp1\n");

        // Test against hashCode spec
        if (bp1.hashCode() != bp1.getName().hashCode())
            sb.append("bp1 hashCode not spec consistent\n");
        if (bp2.hashCode() != bp2.getName().hashCode())
            sb.append("bp2 hashCode not spec consistent\n");

        // Test against equals spec
        if (bp1.getName().equals(bp2.getName())) {
            if (!bp1.equals(bp2)) {
                sb.append("BP breaks equals spec\n");
            }
        }
        if (!bp1.getName().equals(bp2.getName())) {
            if (bp1.equals(bp2)) {
                sb.append("BP breaks equals spec in another way\n");
            }
        }

        // Tests against common knowledge: If equals, then hashCode should be same
        if (bp1.equals(bp2)) {
            if (bp1.hashCode() != bp2.hashCode()) {
                sb.append("Equal objects have unequal hashCode?\n");
            }
        }

        if (sb.length() > 0) {
View Full Code Here

      e.printStackTrace();
    }
    ProtectionDomain pd = c.getProtectionDomain();
    PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
    Class<?> myPermission = Class.forName("mypackage.MyPermission");
    BasicPermission myperm = (BasicPermission) myPermission.newInstance();
    System.out.println(coll.implies(new java.io.FilePermission("test1.txt",
        "write"))
        + ","
        + coll.implies(myperm)
        + ","
View Full Code Here

        assertTrue(dp1.equals(dp1));
        assertFalse(dp1.equals(new DelegationPermission("\"aaa\" \"bbb\"")));
        assertTrue(dp2.equals(dp1));
        assertTrue(dp1.equals(dp2));
        assertTrue(dp1.hashCode() == dp2.hashCode());
        assertFalse(dp1.equals(new BasicPermission("\"AAA\""){}));
    }
View Full Code Here

    /**
     * @tests java.lang.Class#getClasses()
     */
    public void test_getClasses_subtest0() {
        final Permission privCheckPermission = new BasicPermission("Privilege check") {
            private static final long serialVersionUID = 1L;
        };

        class MyCombiner implements DomainCombiner {
            boolean combine;
View Full Code Here

      e.printStackTrace();
    }
    ProtectionDomain pd = c.getProtectionDomain();
    PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
    Class<?> myPermission = Class.forName("mypackage.MyPermission");
    BasicPermission myperm = (BasicPermission) myPermission.newInstance();
    System.out.println(
            coll.implies(new java.io.FilePermission("test1.txt", "write"))
        + ","
        + coll.implies(myperm)
                + ","
View Full Code Here

     * implied only by AllPermission
     */
    public void testImplies() {
        Permissions ps = new Permissions();
        Permission ap = new AllPermission();
        Permission bp1 = new BasicPermission("jhb23jhg5") {
        };
        Permission bp2 = new BasicPermission("&%#&^$HJVH") {

            public PermissionCollection newPermissionCollection() {
                return null;
            }
        };
View Full Code Here

public class FailureDebugOption {

   public static void main (String argv[]) throws Exception {
        try {
            AccessController.checkPermission(
                        new BasicPermission("no such permission"){});
        } catch (NullPointerException npe) {
           throw new Exception("Unexpected NullPointerException for security" +
                        " debug option, -Djava.security.debug=failure");
        } catch (AccessControlException ace) {
        }
View Full Code Here

TOP

Related Classes of java.security.BasicPermission$BasicPermissionCollection

Copyright © 2018 www.massapicom. 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.