Package gabriel.acl

Examples of gabriel.acl.Acl


    boolean negative = false;

    Principal principal = null;
    List permissions = new ArrayList();

    Acl acl = new Acl(owner, name);

    int PERMISSIONS = 1;
    int PRINCIPAL = 2;

    int state = PRINCIPAL;

    for (StringTokenizer stringTokenizer = new StringTokenizer(input, " \n{}", true);
         stringTokenizer.hasMoreTokens();) {

      String t = stringTokenizer.nextToken();

      if (" ".equals(t) || "\n".equals(t)) {
        // do nothing
      } else if ("{".equals(t)) {
        state = PERMISSIONS;
         } else if ("}".equals(t)) {
        state = PRINCIPAL;

        AclEntry entry = new AclEntry(principal);
        Iterator iterator = permissions.iterator();
        while (iterator.hasNext()) {
          Permission permission = (Permission) iterator.next();
          entry.addPermission(permission);
        }
        if (negative) {
          entry.setNegativePermissions();
          negative = false;
        }
        acl.addEntry(owner, entry);
        permissions = new ArrayList();
        principal = null;
      } else if (state == PRINCIPAL) {
        if (t.startsWith("-")) {
          negative = true;
View Full Code Here


  protected void setUp() throws Exception {
    super.setUp();
    accessManager = new AccessManagerImpl(new AclStore() {
      public Acl getAcl(Principal owner, String name) {
        return new Acl(owner, name);
      }
    });
  }
View Full Code Here

    FileAclStore manager = new FileAclStore();
    String source = "PP1 { PM1 PM2 \n" +
        "                  PM3 }" +
        "            PP2 { PM1 }";

    Acl acl = manager.parse(owner, name, new StringReader(source));

    assertEquals("PP1 has PM1",
        1, acl.checkPermission(new Principal("PP1"), new Permission("PM1")));
    assertEquals("PP1 has PM2",
        1, acl.checkPermission(new Principal("PP1"), new Permission("PM2")));
    assertEquals("PP1 has PM3",
        1, acl.checkPermission(new Principal("PP1"), new Permission("PM3")));
    assertEquals("PP2 has PM1",
        1, acl.checkPermission(new Principal("PP2"), new Permission("PM1")));
  }
View Full Code Here

  public void testNegativePermissions() {
    FileAclStore manager = new FileAclStore();
    String source = "-PP1 { PM1 }";

    Acl acl = manager.parse(owner, name, new StringReader(source));

    assertEquals("PP1 is denied PM1",
        -1, acl.checkPermission(new Principal("PP1"), new Permission("PM1")));

  }
View Full Code Here

  }

  protected void setUp() throws Exception {
    super.setUp();
    owner = new Principal("Owner");
    acl = new Acl(owner, "TestAcl");
  }
View Full Code Here

TOP

Related Classes of gabriel.acl.Acl

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.