use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testAddInvalidEntry2.
public void testAddInvalidEntry2() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.addAccessControlEntry(testPrincipal, new Privilege[0]);
fail("Adding an ACE with invalid privileges should fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testRemoveInvalidEntry.
public void testRemoveInvalidEntry() throws RepositoryException {
JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
try {
pt.removeAccessControlEntry(new JackrabbitAccessControlEntry() {
public boolean isAllow() {
return false;
}
public String[] getRestrictionNames() {
return new String[0];
}
public Value getRestriction(String restrictionName) {
return null;
}
public Value[] getRestrictions(String restrictionName) throws RepositoryException {
return null;
}
@Override
public PrivilegeCollection getPrivilegeCollection() throws RepositoryException {
throw new UnsupportedRepositoryOperationException();
}
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
try {
return privilegesFromName(Privilege.JCR_READ);
} catch (Exception e) {
return new Privilege[0];
}
}
});
fail("Passing an unknown ACE should fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class AbstractACLTemplateTest method testReorderInvalidElements.
public void testReorderInvalidElements() throws Exception {
Privilege[] read = privilegesFromName(Privilege.JCR_READ);
Privilege[] write = privilegesFromName(Privilege.JCR_WRITE);
Principal p2 = getSecondPrincipal();
AbstractACLTemplate acl = (AbstractACLTemplate) createEmptyTemplate(getTestPath());
acl.addAccessControlEntry(testPrincipal, read);
acl.addAccessControlEntry(p2, write);
AbstractACLTemplate acl2 = (AbstractACLTemplate) createEmptyTemplate(getTestPath());
acl2.addEntry(testPrincipal, write, false);
AccessControlEntry invalid = acl2.getEntries().get(0);
try {
acl.orderBefore(invalid, acl.getEntries().get(0));
fail("src entry not contained in list -> reorder should fail.");
} catch (AccessControlException e) {
// success
}
try {
acl.orderBefore(acl.getEntries().get(0), invalid);
fail("dest entry not contained in list -> reorder should fail.");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class PrivilegeRegistryTest method testGetBitsFromInvalidAggregatePrivilege.
public void testGetBitsFromInvalidAggregatePrivilege() throws RepositoryException {
Privilege p = buildUnregisteredPrivilege("anyName", privilegeRegistry.getPrivilege(Privilege.JCR_WRITE));
try {
PrivilegeRegistry.getBits(new Privilege[] { p });
fail("Retrieving bits from unknown privilege should fail.");
} catch (AccessControlException e) {
// ok
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit by apache.
the class PrivilegeManagerImplTest method testGetBitsFromCustomAggregatePrivilege.
public void testGetBitsFromCustomAggregatePrivilege() throws RepositoryException {
Privilege p = buildCustomPrivilege("anyName", privilegeMgr.getPrivilege(Privilege.JCR_WRITE));
try {
getPrivilegeManagerImpl().getBits(p);
fail("Retrieving bits from unknown privilege should fail.");
} catch (AccessControlException e) {
// ok
}
}
Aggregations