Package net.jini.security

Examples of net.jini.security.GrantPermission$Implier


     * operation of the provider, which can result in deadlock as described by
     * bug 4911907.
     */
    private void ensureDependenciesResolved() {
  // force resolution of GrantPermission and UmbrellaGrantPermission
  new GrantPermission(new UmbrellaGrantPermission());
    }
View Full Code Here


    }

    private static void expandUmbrella(PermissionCollection pc) {
  if (pc.implies(new UmbrellaGrantPermission())) {
      List l = Collections.list(pc.elements());
      pc.add(new GrantPermission(
           (Permission[]) l.toArray(new Permission[l.size()])));
  }
    }
View Full Code Here

        /*
         * Create three GrantPermissions passing created FilePermissions
         * with "read", "write" and "read,write" actions.
         */
        GrantPermission gp01 = new GrantPermission(fp01);
        GrantPermission gp02 = new GrantPermission(fp02);
        GrantPermission gp03 = new GrantPermission(fp03);

        /*
         * Create GrantPermission passing array of two created
         * GrantPermissions for "read" and "write" actions.
         */
        Permission[] pa = { fp01, fp02 };
        GrantPermission gppa = new GrantPermission(pa);

        /*
         * Verify that last created GrantPermission implies
         * GrantPermission that was created
         * for "read,write" action.
View Full Code Here

        Permission pm06 = new RuntimePermission("F");
        Permission[] pa01 = new Permission[] { pm01 };
        Permission[] pa02 = new Permission[] { pm01, pm02 };
        Permission[] pa03 = new Permission[] { pm01, pm02, pm03 };
        Permission[] pa04 = new Permission[] { pm01, pm02, pm03, pm04 };
        GrantPermission gp01, gp02, gp03, gp04, gp05, gp06, gp07;
        GrantPermission[] ga = null;
        String passUtil = "com.sun.jini.test.spec.policyprovider.util.";
        String nameQA01 = "QAPermission01";
        String badname01 = "Foo | \"a \\\"quoted\\\" string\"";
        String badname02 = "Foo a \\\"quoted\\\" string\"";
        String badname03 = "Foo \"a \"quoted\\\" string\"";
        String badname04 = "Foo \"a \\\"quoted\" string\"";
        String badname05 = "Foo \"a \\\"quoted\\\" string\";;";
        String badname06 = "delim=|| Foo | a \"quoted\" string|";
        String badname07 = "delim=| | Foo | a \"quoted\" string|";
        String badname08 = "delim=| Foo a \"quoted\" string|";
        String badname09 = "delim=| Foo || a \"quoted\" string|";
        String badname10 = "delim=| Foo | a \"quoted\" string||";
        String name01 = "Foo \"a \\\"quoted\\\" string\"";
        String name02 = "Bar \"a \\\"quoted\\\" string\"";
        String name03 = "delim=| Foo | a \"quoted\" string|";
        String name04 = "delim=| Bar | a \"quoted\" string|";

        /*
         * Try to construct GrantPermission object passing null as
         * Permission and verify that NullPointerException is
         * thrown.
         */
        msg = "new GrantPermission((Permission) null)";
        createGrantPermissionNPE((Permission) null, msg);

        /*
         * Try to construct GrantPermission object passing null as
         * array of Permissions and verify that NullPointerException is
         * thrown.
         */
        msg = "new GrantPermission((Permission[]) null)";
        createGrantPermissionNPE((Permission[]) null, msg);

        /*
         * Some times try to construct GrantPermission object passing
         * various array of Permissions that contains null and verify
         * that NullPointerExceptions are thrown.
         */
        msg = "new GrantPermission(new Permission[] {..., null,... })";
        pma = new Permission[] { null };
        createGrantPermissionNPE(pma, msg);
        pma = new Permission[] { null, pm01, pm02, pm03 };
        createGrantPermissionNPE(pma, msg);
        pma = new Permission[] { pm01, null, pm02, pm03 };
        createGrantPermissionNPE(pma, msg);
        pma = new Permission[] { pm01, null, pm02, pm03, null };
        createGrantPermissionNPE(pma, msg);

        /*
         * Try to construct GrantPermission object passing null as the
         * string name of permission and verify that NullPointerException
         * is thrown.
         */
        msg = "new GrantPermission((String) null)";
        createGrantPermissionNPE((String) null, msg);

        /*
         * Try to construct GrantPermission object passing empty
         * string and verify that IllegalArgumentException is
         * thrown.
         */
        createGrantPermissionIAE("");

        /*
         * Some times try to construct GrantPermission object passing
         * string that cannot be parsed and verify that
         * IllegalArgumentExceptions are thrown.
         * Strings to be passed:
         * "Foo | \"a \\\"quoted\\\" string\""
         * "Foo a \\\"quoted\\\" string\""
         * "Foo \"a \"quoted\\\" string\""
         * "Foo \"a \\\"quoted\" string\""
         * "Foo \"a \\\"quoted\\\" string\";;"
         * "delim=|| Foo | a \"quoted\" string|"
         * "delim=| | Foo | a \"quoted\" string|"
         * "delim=| Foo a \"quoted\" string|"
         * "delim=| Foo || a \"quoted\" string|"
         * "delim=| Foo | a \"quoted\" string||"
         */
        createGrantPermissionIAE(badname01);
        createGrantPermissionIAE(badname02);
        createGrantPermissionIAE(badname03);
        createGrantPermissionIAE(badname04);
        createGrantPermissionIAE(badname05);
        createGrantPermissionIAE(badname06);
        createGrantPermissionIAE(badname07);
        createGrantPermissionIAE(badname08);
        createGrantPermissionIAE(badname09);
        createGrantPermissionIAE(badname10);

        /*
         * Some times try to construct GrantPermission object passing
         * the same string that can be parsed and verify that
         * no exception is thrown.
         */
        gp01 = createGP(name01);
        gp02 = createGP(name01);
        gp03 = createGP(name01);

        /*
         * Verify that all created GrantPermissions are equal and
         * have the same hash code and are implied each other.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03 };
        checkEquals(ga, true);
        checkImplies(ga, true);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object passing
         * different strings that can be parsed and verify that
         * no exception is thrown.
         */
        gp01 = createGP(name01);
        gp02 = createGP(name02);
        gp03 = createGP(name03);
        gp04 = createGP(name04);

        /*
         * Verify that all created GrantPermissions are not equal and
         * are not implied each other.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03, gp04 };
        checkEquals(ga, false);
        checkImplies(ga, false);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object passing
         * the same RuntimePermission and verify that
         * no exception is thrown.
         */
        gp01 = createGP(pm01);
        gp02 = createGP(pm01);
        gp03 = createGP(pm01);

        /*
         * Verify that all created GrantPermissions are equal and
         * have the same hash code and are implied each other.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03 };
        checkEquals(ga, true);
        checkImplies(ga, true);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object passing
         * different RuntimePermissions and verify that
         * no exception is thrown.
         */
        gp01 = createGP(pm01);
        gp02 = createGP(pm02);
        gp03 = createGP(pm03);
        gp04 = createGP(pm04);

        /*
         * Verify that all created GrantPermissions are not equal and
         * are not implied each other.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03, gp04 };
        checkEquals(ga, false);
        checkImplies(ga, false);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object passing
         * the same array of RuntimePermission and verify that
         * no exception is thrown.
         */
        gp01 = createGP(pa01);
        gp02 = createGP(pa01);
        gp03 = createGP(pa01);

        /*
         * Verify that all created GrantPermissions are equal and
         * have the same hash code and are implied each other.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03 };
        checkEquals(ga, true);
        checkImplies(ga, true);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object passing
         * different arrays of RuntimePermissions and verify that
         * no exception is thrown.
         * Each next array of RuntimePermissions should contain array from
         * previous RuntimePermissions plus the new one RuntimePermission:
         * {p1}
         * {p1, p2}
         * {p1, p2, p3}
         * ...
         */
        gp01 = createGP(pa01);
        gp02 = createGP(pa02);
        gp03 = createGP(pa03);
        gp04 = createGP(pa04);

        /*
         * Verify that all created GrantPermissions are not equal and
         * are implied/not implied each other. Also verify that if two
         * GrantPermission instances are equal to one another then they
         * should have the same hash code.
         * Verify that getActions() returns empty string for all
         * created GrantPermissions.
         */
        ga = new GrantPermission[] { gp01, gp02, gp03, gp04 };
        checkEquals(ga, false);
        checkImplies(ga);
        checkGetActions(ga);

        /*
         * Some times try to construct GrantPermission object using
         * strings with different delimeters and not using delimeters
         * at all and verify that no exception is thrown.
         * Strings to be passed:
         * "delim=? java.lang.RuntimePermission ?foo?"
         * "delim=| java.lang.RuntimePermission |foo|"
         * "delim=] java.lang.RuntimePermission ]foo]"
         * "delim=[ java.lang.RuntimePermission [foo["
         * "delim=* java.lang.RuntimePermission *foo*"
         * "java.lang.RuntimePermission \"foo\""
         */
        gp01 = createGP("delim=? java.lang.RuntimePermission ?foo?");
        gp02 = createGP("delim=| java.lang.RuntimePermission |foo|");
        gp03 = createGP("delim=] java.lang.RuntimePermission ]foo]");
        gp04 = createGP("delim=[ java.lang.RuntimePermission [foo[");
        gp05 = createGP("delim=* java.lang.RuntimePermission *foo*");
        gp06 = createGP("java.lang.RuntimePermission \"foo\"");
  gp07 = createGP(new RuntimePermission("foo"));
        ga = new GrantPermission[] { gp01, gp02, gp03, gp04, gp05, gp06, gp07 };

        /*
         * Verify that all created GrantPermissions are equal and
         * have the same hash code and are implied each other.
         */
        checkEquals(ga, true);
        checkImplies(ga, true);

        /*
         * For application-defined permissions type that can not be loaded
         * do the following:
         * two times try to construct GrantPermission object passing
         * the same application-defined permissions type as a string;
         * Verify that no exception is thrown.
         */
        gp01 = createGP(passUtil + "bar" + " \"foo\"");
        gp02 = createGP(passUtil + "bar" + " \"foo\"");
        ga = new GrantPermission[] { gp01, gp02 };

        /*
         * Verify that all created GrantPermissions are equal and
         * have the same hash code and are implied each other.
         */
        checkEquals(ga, true);
        checkImplies(ga, true);

        /*
         * For application-defined permissions type that can be loaded
         * do the following:
         * two times try to construct GrantPermission object passing
         * the same application-defined permissions type as a string;
         * two times try to construct GrantPermission object passing
         * the same application-defined permissions type as an object.
         * Use QAPermission01 class for this test case.
         * Verify that no exception is thrown.
         */
        gp01 = createGP(passUtil + nameQA01 + " \"foo\"");
        gp02 = createGP(passUtil + nameQA01 + " \"foo\"");
        gp03 = createGP(new QAPermission01("foo"));
        gp04 = createGP(new QAPermission01("foo"));
        ga = new GrantPermission[] { gp01, gp02, gp03, gp04 };

        /*
   * The string forms should be .equals to each other
   * The object forms should be .equals to each other
   * The string forms should imply the object forms, but
   * The object forms should not imply the string forms
   * This is because the string forms are unresolved, since
   * QAPermission01 isn't visible to the extension class loader,
   * so that the string form is effectively a superset of
   * the object form.
         */
  if (! gp01.equals(gp02)) {
            throw new TestException("gp01 not .equals gp02");
        }

  if (! gp02.equals(gp01)) {
            throw new TestException("gp02 not .equals gp01");
        }

  if (! gp03.equals(gp04)) {
            throw new TestException("gp03 not .equals gp04");
        }

  if (! gp04.equals(gp03)) {
            throw new TestException("gp04 not .equals gp03");
        }

  if (! gp01.implies(gp03)) {
            throw new TestException("gp01 doesn't imply gp03");
        }

  if (gp03.implies(gp01)) {
            throw new TestException("gp03 incorrectly implies gp01");
View Full Code Here

     *
     */
    protected void createGrantPermissionNPE(Permission p, String msg)
            throws TestException {
        try {
            GrantPermission gp = new GrantPermission(p);
            throw new TestException(Util.fail(msg, msg, NPE));
        } catch (NullPointerException npe) {
            logger.log(Level.FINE, Util.pass(msg, npe));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

     *
     */
    protected void createGrantPermissionNPE(Permission[] pa, String msg)
            throws TestException {
        try {
            GrantPermission gp = new GrantPermission(pa);
            throw new TestException(Util.fail(msg, msg, NPE));
        } catch (NullPointerException npe) {
            logger.log(Level.FINE, Util.pass(msg, npe));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

     *
     */
    protected void createGrantPermissionNPE(String name, String msg)
            throws TestException {
        try {
            GrantPermission gp = new GrantPermission(name);
            throw new TestException(Util.fail(msg, msg, NPE));
        } catch (NullPointerException npe) {
            logger.log(Level.FINE, Util.pass(msg, npe));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

    protected void createGrantPermissionIAE(String name)
            throws TestException {
        msg = "new GrantPermission(" + name + ")";

        try {
            GrantPermission gp = new GrantPermission(name);
            throw new TestException(Util.fail(msg, msg, IAE));
        } catch (IllegalArgumentException iae) {
            logger.log(Level.FINE, Util.pass(msg, iae));
        } catch (TestException qae) {
            throw qae;
View Full Code Here

     *
     */
    protected GrantPermission createGP(Permission p)
            throws TestException {
        msg = "new GrantPermission(" + p.getName() + ")";
        GrantPermission gp = null;

        try {
            gp = new GrantPermission(p);
        } 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

     */
    protected GrantPermission createGP(Permission[] pa)
            throws TestException {
        String arg = java.util.Arrays.asList(pa).toString();
        msg = "new GrantPermission(" + arg + ")";
        GrantPermission gp = null;

        try {
            gp = new GrantPermission(pa);
        } 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

TOP

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

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.