use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testWriteUnsupportedRestrictions.
@Test
public void testWriteUnsupportedRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
Restriction invalid = new RestrictionImpl(PropertyStates.createProperty("invalid", vf.createValue(true)), false);
try {
provider.writeRestrictions("/test", aceNode.getTree(), ImmutableSet.<Restriction>of(invalid));
fail("AccessControlException expected");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class ACLTest method testInvalidRestrictionType.
@Test
public void testInvalidRestrictionType() throws Exception {
RestrictionProvider rp = new TestRestrictionProvider("restr", Type.NAME, false);
JackrabbitAccessControlList acl = createACL(TEST_PATH, new ArrayList(), namePathMapper, rp);
try {
acl.addEntry(testPrincipal, testPrivileges, false, Collections.<String, Value>singletonMap("restr", getValueFactory().createValue(true)));
fail("Invalid restriction type.");
} catch (AccessControlException e) {
// mandatory restriction missing -> success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class ACLTest method testRemoveInvalidEntry.
@Test
public void testRemoveInvalidEntry() throws Exception {
try {
acl.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) {
return null;
}
public Principal getPrincipal() {
return testPrincipal;
}
public Privilege[] getPrivileges() {
return testPrivileges;
}
});
fail("Passing an unknown ACE should fail");
} catch (AccessControlException e) {
// success
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testRemoveInvalidPolicy.
@Test
public void testRemoveInvalidPolicy() throws Exception {
List<AccessControlPolicy> invalidPolicies = ImmutableList.of(new AccessControlPolicy() {
}, new NamedAccessControlPolicy() {
public String getName() {
return "name";
}
}, InvalidCug.INSTANCE);
for (AccessControlPolicy policy : invalidPolicies) {
try {
cugAccessControlManager.removePolicy(SUPPORTED_PATH, policy);
fail("Invalid cug policy must be detected.");
} catch (AccessControlException e) {
// success
}
}
}
use of javax.jcr.security.AccessControlException in project jackrabbit-oak by apache.
the class ACL method orderBefore.
@Override
public void orderBefore(AccessControlEntry srcEntry, AccessControlEntry destEntry) throws RepositoryException {
ACE src = checkACE(srcEntry);
ACE dest = (destEntry == null) ? null : checkACE(destEntry);
if (src.equals(dest)) {
log.debug("'srcEntry' equals 'destEntry' -> no reordering required.");
return;
}
int index = (dest == null) ? entries.size() - 1 : entries.indexOf(dest);
if (index < 0) {
throw new AccessControlException("'destEntry' not contained in this AccessControlList.");
} else {
if (entries.remove(src)) {
// re-insert the srcEntry at the new position.
entries.add(index, src);
} else {
// src entry not contained in this list.
throw new AccessControlException("srcEntry not contained in this AccessControlList");
}
}
}
Aggregations