use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlListTest method testAddAccessControlEntryInvalidPrivilege.
public void testAddAccessControlEntryInvalidPrivilege() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
try {
Privilege[] invalidPrivs = new Privilege[] { new Privilege() {
public String getName() {
return null;
}
public boolean isAbstract() {
return false;
}
public boolean isAggregate() {
return false;
}
public Privilege[] getDeclaredAggregatePrivileges() {
return new Privilege[0];
}
public Privilege[] getAggregatePrivileges() {
return new Privilege[0];
}
} };
AccessControlList acl = getList(acMgr, path);
acl.addAccessControlEntry(testPrincipal, invalidPrivs);
fail("Adding an entry with an invalid privilege must throw AccessControlException.");
} catch (AccessControlException e) {
// success.
} finally {
superuser.refresh(false);
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlListTest method testAddAccessControlEntryInvalidPrincipal.
public void testAddAccessControlEntryInvalidPrincipal() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
try {
Principal invalidPrincipal = getHelper().getUnknownPrincipal(superuser);
AccessControlList acl = getList(acMgr, path);
acl.addAccessControlEntry(invalidPrincipal, privs);
fail("Adding an entry with an unknown principal must throw AccessControlException.");
} catch (AccessControlException e) {
// success.
} finally {
superuser.refresh(false);
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlListTest method testRemoveIllegalAccessControlEntry.
public void testRemoveIllegalAccessControlEntry() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
try {
AccessControlEntry entry = new AccessControlEntry() {
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
return privs;
}
};
AccessControlList acl = getList(acMgr, path);
acl.removeAccessControlEntry(entry);
fail("AccessControlManager.removeAccessControlEntry with an unknown entry must throw AccessControlException.");
} catch (AccessControlException e) {
// ok
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlListTest method testAddAccessControlEntryEmptyPrivilegeArray.
public void testAddAccessControlEntryEmptyPrivilegeArray() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
try {
Privilege[] invalidPrivs = new Privilege[0];
AccessControlList acl = getList(acMgr, path);
acl.addAccessControlEntry(testPrincipal, invalidPrivs);
fail("Adding an entry with an invalid privilege array must throw AccessControlException.");
} catch (AccessControlException e) {
// success.
} finally {
superuser.refresh(false);
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AccessControlListTest method testAddAbstractPrivilege.
public void testAddAbstractPrivilege() throws NotExecutableException, RepositoryException {
checkCanModifyAc(path);
Privilege abstractPriv = null;
Privilege[] allPrivs = acMgr.privilegeFromName(Privilege.JCR_ALL).getAggregatePrivileges();
for (int i = 0; i < allPrivs.length; i++) {
if (allPrivs[i].isAbstract()) {
abstractPriv = allPrivs[i];
break;
}
}
if (abstractPriv == null) {
throw new NotExecutableException("No abstract privilege found.");
}
AccessControlList acl = getList(acMgr, path);
try {
acl.addAccessControlEntry(testPrincipal, new Privilege[] { abstractPriv });
fail("Adding an ACE with an abstract privilege must fail.");
} catch (AccessControlException e) {
// success
}
}
Aggregations