Package net.jini.security

Examples of net.jini.security.GrantPermission$PermissionInfo


     *
     */
    protected GrantPermission createGP(String name)
            throws TestException {
        msg = "new GrantPermission(" + name + ")";
        GrantPermission gp = null;

        try {
            gp = new GrantPermission(name);
        } catch (Exception e) {
            throw new TestException(Util.fail(msg, e, msg));
        }
        logger.log(Level.FINE, Util.pass(msg, "creates GrantPermission"));
        return gp;
View Full Code Here


    /**
     * Run the test according <b>Test Description</b>
     */
    public void run() throws Exception {
        Permission pu1 = new GrantPermission(new RuntimePermission("A"));
        Permission pu2 = new GrantPermission(new RuntimePermission("B"));
        Permission pu3 = new GrantPermission(new RuntimePermission("C"));
        Permission pu4 = new GrantPermission(new RuntimePermission("D"));
        Permission pu5 = new GrantPermission(new RuntimePermission("E"));
        Permission puX = new GrantPermission(new RuntimePermission("X"));
        Permission puY = new GrantPermission(new RuntimePermission("Y"));
        Permission puZ = new GrantPermission(new RuntimePermission("Z"));
        Permission puP = new GrantPermission(new RuntimePermission("P"));
        Permission pm1 = new RuntimePermission("A");
        Permission pm2 = new RuntimePermission("B");
        Permission pm3 = new RuntimePermission("C");
        Permission pm4 = new RuntimePermission("D");
        Permission pm5 = new RuntimePermission("E");
View Full Code Here

  permissions = (Permission[]) permissions.clone();
  checkNullElements(permissions);

  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
      sm.checkPermission(new GrantPermission(permissions));
  }

  Grants g = (cl != null) ?
      getLoaderGrants(getClassLoader(cl)) : globalGrants;
  g.add(principals, permissions);
View Full Code Here

            // PASS
            logger.fine("Method threw UnsupportedOperationException "
                    + "as expected.");
        }
        Permission[] testPerm = new Permission[] {
            new GrantPermission(new SecurityPermission("getPolicy")),
            new GrantPermission(new PropertyPermission("*", "read")),
            new GrantPermission(new FilePermission("*", "read")),
            new GrantPermission(new RuntimePermission("getClassLoader")) };
        Principal testPrin = new FakePrincipal();
        Subject subj = new Subject();
        subj.getPrincipals().add(testPrin);
        TestDynamicPolicyProvider policy =
                new TestDynamicPolicyProvider(testPerm);
        logger.fine("Policy provider is " + policy);
        Policy.setPolicy(policy);
        Subject.doAs(subj, new FakePrivilegedAction(fromClass, toClass));
        Object[] params = policy.getGetGrantsParams();

        if (params == null || params.length == 0) {
            // FAIL
            throw new TestException(
                    "'getGrants' method of " + policy + " was not called.");
        }

        if (!params[0].equals(fromClass)) {
            // FAIL
            throw new TestException(
                    "1-st parameter to 'getGrants' was " + params[0]
                    + " while " + fromClass + " was expected.");
        }

        if (params[1] == null || ((Object []) params[1]).length != 1
                || !((Object []) params[1])[0].equals(testPrin)) {
            // FAIL
            throw new TestException(
                    "2-nd parameter to 'getGrants' was "
                    + Util.arrayToString((Object []) params[1])
                    + " while " + testPrin + " was expected.");
        }

        // PASS
        logger.fine("'getGrants' method of installed policy provider "
                + " was called with correct parameters.");
        params = policy.getGrantParams();

        if (params == null || params.length == 0) {
            // FAIL
            throw new TestException(
                    "'grant' method of " + policy + " was not called.");
        }

        if (!params[0].equals(toClass)) {
           // FAIL
           throw new TestException(
                   "1-st parameter was " + params[0]
                   + " while " + toClass + " was expected.");
        }

        if (params[1] == null || ((Object []) params[1]).length != 1
                || !((Object []) params[1])[0].equals(testPrin)) {
            // FAIL
            throw new TestException(
                    "2-nd parameter was "
                    + Util.arrayToString((Object []) params[1])
                    + " while " + testPrin + " was expected.");
        }

        if (!Util.comparePermissions((Object []) params[2], testPerm)) {
          // FAIL
            throw new TestException(
                    "3-rd parameter was "
                    + Util.arrayToString((Object []) params[2])
                    + " while " + Util.arrayToString(testPerm)
                    + " was expected.");
        }

        // PASS
        logger.fine("'grant' method of installed policy provider "
                + " was called with correct parameters.");

        // not granted list of permissions
        Permission[] notGrantedPerm = new Permission[] {
            new GrantPermission(new PropertyPermission("*", "read")),
            new GrantPermission(new RuntimePermission("getClassLoader")) };
        policy = new TestDynamicPolicyProvider(testPerm, notGrantedPerm);
        logger.fine("Policy provider is " + policy);
        Policy.setPolicy(policy);
        Subject.doAs(subj, new FakePrivilegedAction(fromClass, toClass));
        params = policy.getGetGrantsParams();
View Full Code Here

TOP

Related Classes of net.jini.security.GrantPermission$PermissionInfo

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.