boolean validatedJavaCompEnvACL = false;
// validate the two ACLs returned.
for (ACL acl : configuredACLs)
{
ACLImpl aclImpl = (ACLImpl) acl;
if (aclImpl.getResourceAsString().equals("org.jboss.test.authorization.acl.ACLTestResource:10"))
{
assertEquals("Invalid number of entries", 2, aclImpl.getEntries().size());
// one entry should assign the CREATE,READ,UPDATE,DELETE permissions to Administrator.
ACLEntry entry = aclImpl.getEntry(IdentityFactory.createIdentity("Administrator"));
assertNotNull("Unexpected null value for Administrator entry", entry);
CompositeACLPermission expectedPermission = new CompositeACLPermission(BasicACLPermission.values());
assertEquals("Unexpected permissions assigned for Administrator", expectedPermission, entry.getPermission());
// the other entry should assign the READ permission to Guest.
entry = aclImpl.getEntry(IdentityFactory.createIdentity("Guest"));
assertNotNull("Unexpected null value for Guest entry", entry);
expectedPermission = new CompositeACLPermission(BasicACLPermission.READ);
assertEquals("Unexpected permissions assigned for Guest", expectedPermission, entry.getPermission());
validatedJavaCompACL = true;
}
else if (aclImpl.getResourceAsString().equals("org.jboss.test.authorization.acl.ACLTestResource:20"))
{
assertEquals("Invalid number of entries", 3, aclImpl.getEntries().size());
// one entry should assign the CREATE,READ,UPDATE,DELETE permissions to Administrator.
ACLEntry entry = aclImpl.getEntry(IdentityFactory.createIdentity("Administrator"));
assertNotNull("Unexpected null value for Administrator entry", entry);
CompositeACLPermission expectedPermission = new CompositeACLPermission(BasicACLPermission.values());
assertEquals("Unexpected permissions assigned for Administrator", expectedPermission, entry.getPermission());
// one other entry should assign the READ,UPDATE permissions to Guest.
entry = aclImpl.getEntry(IdentityFactory.createIdentity("Guest"));
assertNotNull("Unexpected null value for Guest entry", entry);
expectedPermission = new CompositeACLPermission(BasicACLPermission.READ, BasicACLPermission.UPDATE);
assertEquals("Unexpected permissions assigned for Guest", expectedPermission, entry.getPermission());
// the final entry should assign the READ,UPDATE permissions to Regular_User.
entry = aclImpl.getEntry(IdentityFactory.createIdentity("Regular_User"));
assertNotNull("Unexpected null value for Regular_User entry", entry);
expectedPermission = new CompositeACLPermission(BasicACLPermission.READ, BasicACLPermission.UPDATE);
assertEquals("Unexpected permissions assigned for Regular_User", expectedPermission, entry.getPermission());
validatedJavaCompEnvACL = true;
}
else
fail("Invalid ACL found: " + aclImpl.getResourceAsString());
}
assertTrue("org.jboss.jnp.NamingService:java/comp ACL has not been validated", validatedJavaCompACL);
assertTrue("org.jboss.jnp.NamingService:java/comp/env ACL has not been validated", validatedJavaCompEnvACL);
}