Package gabriel.acl

Examples of gabriel.acl.AclEntry


   *
   * @param principal   Principal to give permissions
   * @param permissions List of permissions to give
   */
  public void addPermission(Principal principal, List permissions) {
    AclEntry entry = new AclEntry(principal);

    Iterator iterator = permissions.iterator();
    while (iterator.hasNext()) {
      Permission permission = (Permission) iterator.next();
      entry.addPermission(permission);
    }
    addEntry(entry);
  }
View Full Code Here


   *
   * @param principal  Principal to give permission
   * @param permission Permission to give
   */
  public void addPermission(Principal principal, Permission permission) {
    AclEntry entry = new AclEntry(principal);
    entry.addPermission(permission);
    addEntry(entry);
  }
View Full Code Here

      } 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;
View Full Code Here

  }

  protected void setUp() throws Exception {
    super.setUp();
    principal = new Principal("TestPrincipal");
    entry = new AclEntry(principal);
    permission = new Permission("TestPermission");
  }
View Full Code Here

    }
  }

  public void testAddAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertTrue("Acl contains added entry.", acl.entries().contains(entry));
  }
View Full Code Here

    assertTrue("Acl contains added entry.", acl.entries().contains(entry));
  }

  public void testAddOneAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertEquals("Acl contains one entry.", 1, acl.entries().size());
  }
View Full Code Here

    assertEquals("Acl contains one entry.", 1, acl.entries().size());
  }

  public void testAddEntryWithWrongOwner() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    try {
      acl.addEntry(new Principal("Owner"), entry);
      fail("Should raise an SecurityException");
    } catch (SecurityException e) {
    }
View Full Code Here

    }
  }

  public void testRemoveAclEntry() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    assertTrue("AclEntry says true to remove.", acl.removeEntry(owner, entry));
    assertTrue("Acl does not contain removed entry.", !acl.entries().contains(entry));
  }
View Full Code Here

    assertTrue("Acl does not contain removed entry.", !acl.entries().contains(entry));
  }

  public void testRemoveEntryWithWrongOwner() {
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    acl.addEntry(owner, entry);
    try {
      acl.removeEntry(new Principal("Owner"), entry);
      fail("Should raise an SecurityException");
    } catch (SecurityException e) {
View Full Code Here

  }

  public void testCheckPermission() {
    Permission permission = new Permission("TestPermission");
    Principal principal = new Principal("TestPrincipal");
    AclEntry entry = new AclEntry(principal);
    entry.addPermission(permission);
    acl.addEntry(owner, entry);

    Principal checkPrincipal = new Principal("TestPrincipal");
    Permission checkPermission = new Permission("TestPermission");
    assertEquals("Principal has permission from entry", 1, acl.checkPermission(checkPrincipal, checkPermission));
View Full Code Here

TOP

Related Classes of gabriel.acl.AclEntry

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.