use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class UserManagementTest method testGlobRestriction.
@Test
public void testGlobRestriction() throws Exception {
String groupHome = Text.getRelativeParent(UserConstants.DEFAULT_GROUP_PATH, 1);
Privilege[] privs = privilegesFromName(PrivilegeConstants.REP_USER_MANAGEMENT);
allow(groupHome, privs);
deny(groupHome, privs, createGlobRestriction("*/" + UserConstants.REP_MEMBERS));
UserManager testUserMgr = getUserManager(testSession);
// creating a new group must be allow
Group gr = testUserMgr.createGroup(groupId);
testSession.save();
// modifying group membership must be denied
try {
gr.addMember(testUserMgr.getAuthorizable(testSession.getUserID()));
testSession.save();
fail();
} catch (AccessDeniedException e) {
// success
} finally {
testSession.refresh(false);
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class SessionMoveTest method testMoveAndAddProperty.
@Test
public void testMoveAndAddProperty() throws Exception {
setupMovePermissions();
testSession.move(nodePath3, siblingDestPath);
Node destNode = testSession.getNode(siblingDestPath);
Property p = destNode.setProperty("newProp", "val");
try {
testSession.save();
fail("Missing ADD_PROPERTY permission.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class SessionMoveTest method testMoveAndAddReplacementAtSource.
@Test
public void testMoveAndAddReplacementAtSource() throws Exception {
allow(path, privilegesFromNames(new String[] { Privilege.JCR_REMOVE_CHILD_NODES, Privilege.JCR_ADD_CHILD_NODES }));
allow(siblingPath, privilegesFromNames(new String[] { PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_NODE_TYPE_MANAGEMENT }));
testSession.move(nodePath3, siblingDestPath);
Node sourceParent = testSession.getNode(childNPath);
Node replacement = sourceParent.addNode(Text.getName(nodePath3));
replacement.setProperty("movedProp", "val");
try {
testSession.save();
fail("Missing ADD_NODE and ADD_PROPERTY permission on source parent.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class SessionMoveTest method testMoveAndAddPropertyAtSource.
@Test
public void testMoveAndAddPropertyAtSource() throws Exception {
setupMovePermissions();
testSession.move(nodePath3, siblingDestPath);
Node n = testSession.getNode(childNPath);
Property p = n.setProperty("newProp", "val");
try {
testSession.save();
fail("Missing ADD_PROPERTY permission.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit-oak by apache.
the class SessionMoveTest method testMoveAndRemovePropertyAtSource.
@Test
public void testMoveAndRemovePropertyAtSource() throws Exception {
setupMovePermissions();
testSession.move(nodePath3, siblingDestPath);
Node n = testSession.getNode(childNPath);
assertTrue(n.hasProperty(propertyName1));
n.getProperty(propertyName1).remove();
try {
testSession.save();
fail("Missing REMOVE_PROPERTY permission.");
} catch (AccessDeniedException e) {
// success
}
}
Aggregations