use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class AbstractAccessControlTest method before.
@Override
@Before
public void before() throws Exception {
super.before();
NodeUtil rootNode = new NodeUtil(root.getTree("/"), getNamePathMapper());
rootNode.addChild("testPath", JcrConstants.NT_UNSTRUCTURED);
root.commit();
testPrincipal = getTestUser().getPrincipal();
testPrivileges = privilegesFromNames(JCR_ADD_CHILD_NODES, JCR_LOCK_MANAGEMENT);
privilegeManager = getPrivilegeManager(root);
principalManager = getPrincipalManager(root);
acl = createEmptyACL();
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testInvalidTokenParentNode.
@Test
public void testInvalidTokenParentNode() throws Exception {
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
NodeUtil node = new NodeUtil(userTree).addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
try {
// Invalid node type of '.tokens' node
node.addChild(TOKENS_NODE_NAME, JcrConstants.NT_UNSTRUCTURED);
root.commit(CommitMarker.asCommitAttributes());
fail("Creating a new token '" + node.getTree().getPath() + "' must fail.");
} catch (CommitFailedException e) {
assertEquals(68, e.getCode());
} finally {
node.getTree().remove();
root.commit(CommitMarker.asCommitAttributes());
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testChangeRegularRepUnstructuredPrimaryType.
@Test
public void testChangeRegularRepUnstructuredPrimaryType() throws Exception {
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
NodeUtil n = new NodeUtil(userTree).getOrAddChild("test", NodeTypeConstants.NT_REP_UNSTRUCTURED);
root.commit();
n.setName(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED);
root.commit();
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testChangeToReservedTokenNodeType.
@Test
public void testChangeToReservedTokenNodeType() throws Exception {
String parentPath = getTestUser().getPath() + "/" + TokenConstants.TOKENS_NODE_NAME;
String path = parentPath + "/node";
try {
Tree t = root.getTree(getTestUser().getPath()).addChild(TokenConstants.TOKENS_NODE_NAME);
t.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
t.addChild("node").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
root.commit();
NodeUtil node = new NodeUtil(root.getTree(path));
node.setName(JcrConstants.JCR_PRIMARYTYPE, TokenConstants.TOKEN_NT_NAME);
node.setString(JcrConstants.JCR_UUID, UUID.randomUUID().toString());
node.setString(TokenConstants.TOKEN_ATTRIBUTE_KEY, PasswordUtil.buildPasswordHash("key"));
node.setDate(TokenConstants.TOKEN_ATTRIBUTE_EXPIRY, new Date().getTime());
root.commit(CommitMarker.asCommitAttributes());
} catch (CommitFailedException e) {
assertEquals(62, e.getCode());
} finally {
root.refresh();
root.getTree(parentPath).remove();
root.commit();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testModifyExpirationDate.
@Test
public void testModifyExpirationDate() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
NodeUtil tokenTree = new NodeUtil(getTokenTree(info));
tokenTree.setDate(TOKEN_ATTRIBUTE_EXPIRY, new Date().getTime());
root.commit(CommitMarker.asCommitAttributes());
}
Aggregations