use of javax.jcr.Node in project jackrabbit by apache.
the class VersionTest method testReadVersionInfo2.
public void testReadVersionInfo2() throws RepositoryException, NotExecutableException {
Node n = createVersionableNode(testRootNode);
modifyPrivileges(VERSION_STORAGE_PATH, Privilege.JCR_READ, true);
Node n2 = (Node) getTestSession().getItem(n.getPath());
n2.getVersionHistory();
n2.getBaseVersion();
}
use of javax.jcr.Node in project jackrabbit by apache.
the class WriteTest method testEditor2.
public void testEditor2() throws NotExecutableException, RepositoryException {
UserManager uMgr = getUserManager(superuser);
User u = null;
User u2 = null;
try {
u = uMgr.createUser("t", "t");
u2 = uMgr.createUser("tt", "tt", new TestPrincipal("tt"), "t/tt");
if (!uMgr.isAutoSave()) {
superuser.save();
}
Principal p = u.getPrincipal();
Principal p2 = u2.getPrincipal();
if (p instanceof ItemBasedPrincipal && p2 instanceof ItemBasedPrincipal && Text.isDescendant(((ItemBasedPrincipal) p).getPath(), ((ItemBasedPrincipal) p2).getPath())) {
JackrabbitAccessControlManager acMgr = (JackrabbitAccessControlManager) getAccessControlManager(superuser);
JackrabbitAccessControlPolicy[] acls = acMgr.getApplicablePolicies(p2);
acMgr.setPolicy(acls[0].getPath(), acls[0]);
acls = acMgr.getApplicablePolicies(p);
String path = acls[0].getPath();
Node n = superuser.getNode(path);
assertEquals("rep:PrincipalAccessControl", n.getPrimaryNodeType().getName());
} else {
throw new NotExecutableException();
}
} finally {
superuser.refresh(false);
if (u2 != null)
u2.remove();
if (u != null)
u.remove();
if (!uMgr.isAutoSave()) {
superuser.save();
}
}
}
use of javax.jcr.Node in project jackrabbit by apache.
the class WriteTest method testAutocreatedProperties.
public void testAutocreatedProperties() throws RepositoryException, NotExecutableException {
givePrivileges(path, testUser.getPrincipal(), privilegesFromName(PrivilegeRegistry.REP_WRITE), getRestrictions(superuser, path));
// test user is not allowed to READ the protected property jcr:created.
Map<String, Value> restr = getRestrictions(superuser, path);
restr.put(((SessionImpl) superuser).getJCRName(ACLTemplate.P_GLOB), superuser.getValueFactory().createValue("/afolder/jcr:created"));
withdrawPrivileges(path, testUser.getPrincipal(), privilegesFromName(Privilege.JCR_READ), restr);
// still: adding a nt:folder node should be possible
Node n = getTestSession().getNode(path);
Node folder = n.addNode("afolder", "nt:folder");
assertFalse(folder.hasProperty("jcr:created"));
}
use of javax.jcr.Node in project jackrabbit by apache.
the class WriteTest method testRemoveNodeWithInvisibleChild.
public void testRemoveNodeWithInvisibleChild() throws Exception {
Privilege[] privileges = privilegesFromNames(new String[] { Privilege.JCR_READ, Privilege.JCR_WRITE });
Node invisible = superuser.getNode(childNPath).addNode(nodeName3);
superuser.save();
/* allow READ/WRITE privilege for testUser at 'path' */
givePrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
/* deny READ privilege at invisible node. (removal is still granted) */
withdrawPrivileges(invisible.getPath(), testUser.getPrincipal(), privilegesFromNames(new String[] { Privilege.JCR_READ }), getRestrictions(superuser, path));
Session testSession = getTestSession();
assertTrue(testSession.nodeExists(childNPath));
assertTrue(testSession.hasPermission(childNPath, Session.ACTION_REMOVE));
Node n = testSession.getNode(childNPath);
// removing the child node must succeed as both remove-node and
// remove-child-nodes are granted to testsession.
// the policy node underneath childNPath should silently be removed
// as the editing session has no knowledge about it's existence.
n.remove();
testSession.save();
}
use of javax.jcr.Node in project jackrabbit by apache.
the class WriteTest method testRemoveNodeWithInvisibleNonRemovableChild.
public void testRemoveNodeWithInvisibleNonRemovableChild() throws Exception {
Privilege[] privileges = privilegesFromNames(new String[] { Privilege.JCR_READ, Privilege.JCR_WRITE });
Node invisible = superuser.getNode(childNPath).addNode(nodeName3);
superuser.save();
/* allow READ/WRITE privilege for testUser at 'path' */
givePrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
/* deny READ privilege at invisible node. (removal is still granted) */
withdrawPrivileges(invisible.getPath(), testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
Session testSession = getTestSession();
assertTrue(testSession.nodeExists(childNPath));
assertTrue(testSession.hasPermission(childNPath, Session.ACTION_REMOVE));
Node n = testSession.getNode(childNPath);
// be removed.
try {
n.remove();
testSession.save();
fail();
} catch (AccessDeniedException e) {
// success
}
}
Aggregations