Fixes to new ACL implementation. Thanks to Nathan Sarr.

This commit is contained in:
Ben Alex 2006-08-30 22:15:29 +00:00
parent a33ce2e7f0
commit 9769394c92
3 changed files with 676 additions and 672 deletions

View File

@ -148,7 +148,7 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
synchronized (aces) {
int offset = findAceOffset(aceId);
if (offset == 1) {
if (offset == -1) {
throw new NotFoundException("Requested ACE ID not found");
}

View File

@ -18,7 +18,6 @@ package org.acegisecurity.acls.domain;
import org.acegisecurity.acls.AclFormattingUtils;
import org.acegisecurity.acls.Permission;
/**
* DOCUMENT ME!
*
@ -31,7 +30,8 @@ public class BasePermission implements Permission {
public static final Permission READ = new BasePermission(1 << 0, 'R'); // 1
public static final Permission WRITE = new BasePermission(1 << 1, 'W'); // 2
public static final Permission CREATE = new BasePermission(1 << 2, 'C'); // 4
public static final Permission ADMINISTRATION = new BasePermission(1 << 3, 'A'); // 8
public static final Permission DELETE = new BasePermission(1 << 3, 'D'); // 8
public static final Permission ADMINISTRATION = new BasePermission(1 << 4, 'A'); // 16
//~ Instance fields ================================================================================================
@ -72,6 +72,10 @@ public class BasePermission implements Permission {
}
if (mask == 8) {
permission.set(DELETE);
}
if (mask == 16) {
permission.set(ADMINISTRATION);
}

View File

@ -29,8 +29,8 @@ public class PermissionTests extends TestCase {
public void testExpectedIntegerValues() {
assertEquals(1, BasePermission.READ.getMask());
assertEquals(8, BasePermission.ADMINISTRATION.getMask());
assertEquals(9, new CumulativePermission().set(BasePermission.READ).set(BasePermission.ADMINISTRATION).getMask());
assertEquals(16, BasePermission.ADMINISTRATION.getMask());
assertEquals(17, new CumulativePermission().set(BasePermission.READ).set(BasePermission.ADMINISTRATION).getMask());
}
public void testStringConversion() {
@ -38,19 +38,19 @@ public class PermissionTests extends TestCase {
assertEquals("BasePermission[...............................R=1]", BasePermission.READ.toString());
System.out.println("A = " + BasePermission.ADMINISTRATION.toString());
assertEquals("BasePermission[............................A...=8]", BasePermission.ADMINISTRATION.toString());
assertEquals("BasePermission[...........................A....=16]", BasePermission.ADMINISTRATION.toString());
System.out.println("R = " + new CumulativePermission().set(BasePermission.READ).toString());
assertEquals("CumulativePermission[...............................R=1]",
new CumulativePermission().set(BasePermission.READ).toString());
System.out.println("A = " + new CumulativePermission().set(BasePermission.ADMINISTRATION).toString());
assertEquals("CumulativePermission[............................A...=8]",
assertEquals("CumulativePermission[...........................A....=16]",
new CumulativePermission().set(BasePermission.ADMINISTRATION).toString());
System.out.println("RA = "
+ new CumulativePermission().set(BasePermission.ADMINISTRATION).set(BasePermission.READ).toString());
assertEquals("CumulativePermission[............................A..R=9]",
assertEquals("CumulativePermission[...........................A...R=17]",
new CumulativePermission().set(BasePermission.ADMINISTRATION).set(BasePermission.READ).toString());
System.out.println("R = "