use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TreePermissionImplTest method testCanReadProperties2.
@Test
public void testCanReadProperties2() throws Exception {
AccessControlManager acMgr = getAccessControlManager(root);
JackrabbitAccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/test");
acl.addEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ), true);
acMgr.setPolicy("/test", acl);
root.commit();
Tree policyTree = root.getTree("/test/rep:policy");
NodeUtil ace = new NodeUtil(policyTree).addChild("ace2", NT_REP_DENY_ACE);
ace.setNames(REP_PRIVILEGES, PrivilegeConstants.REP_READ_PROPERTIES);
ace.setString(REP_PRINCIPAL_NAME, getTestUser().getPrincipal().getName());
root.commit();
TreePermission tp = getTreePermission("/test");
assertFalse(tp.canReadProperties());
assertTrue(tp.canRead());
assertFalse(tp.canReadProperties());
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method getAceTree.
private Tree getAceTree(Restriction... restrictions) throws Exception {
NodeUtil rootNode = new NodeUtil(root.getTree("/"));
NodeUtil tmp = rootNode.addChild("testRoot", JcrConstants.NT_UNSTRUCTURED);
Tree ace = tmp.addChild("rep:policy", NT_REP_ACL).addChild("ace0", NT_REP_GRANT_ACE).getTree();
restrictionProvider.writeRestrictions(tmp.getTree().getPath(), ace, ImmutableSet.copyOf(restrictions));
return ace;
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testGetRestrictionPattern.
@Test
public void testGetRestrictionPattern() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
NodeUtil rNode = aceNode.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS);
rNode.setString(REP_GLOB, "*");
assertFalse(provider.getPattern("/test", aceNode.getTree()) instanceof CompositePattern);
rNode.setBoolean("boolean", true);
rNode.setValues("longs", new Value[] { vf.createValue(10), vf.createValue(290) });
assertTrue(provider.getPattern("/test", rNode.getTree()) instanceof CompositePattern);
}
use of org.apache.jackrabbit.oak.util.NodeUtil 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 org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testReadRestrictions.
@Test
public void testReadRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
aceNode.setBoolean("boolean", true);
aceNode.setValues("longs", new Value[] { vf.createValue(10), vf.createValue(290) });
aceNode.setString(REP_GLOB, "*");
// empty array
aceNode.setNames(REP_NT_NAMES);
aceNode.setString("invalid", "val");
aceNode.setStrings("invalid2", "val1", "val2", "val3");
Set<Restriction> restrictions = provider.readRestrictions("/test", aceNode.getTree());
assertEquals(4, restrictions.size());
for (Restriction r : restrictions) {
String name = r.getDefinition().getName();
if (!supported.contains(name)) {
fail("read unsupported restriction");
}
}
}
Aggregations