use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testUnregisterNamespace.
public void testUnregisterNamespace() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_NAMESPACE_MANAGEMENT);
assertPermission(Permission.NAMESPACE_MNGMT, false);
Workspace wsp = superuser.getWorkspace();
String pfx = getNewNamespacePrefix(wsp);
wsp.getNamespaceRegistry().registerNamespace(pfx, getNewNamespaceURI(wsp));
try {
Workspace testWsp = getTestWorkspace();
testWsp.getNamespaceRegistry().unregisterNamespace(pfx);
fail("Namespace unregistration should be denied.");
} catch (AccessDeniedException e) {
// success
} finally {
// clean up (not supported by jackrabbit-core)
try {
superuser.getWorkspace().getNamespaceRegistry().unregisterNamespace(pfx);
} catch (Exception e) {
// ns unregistration is not supported by jackrabbit-core.
}
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testWorkspaceCreation.
public void testWorkspaceCreation() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_WORKSPACE_MANAGEMENT);
String wspName = getNewWorkspaceName(superuser.getWorkspace());
try {
getTestWorkspace().createWorkspace(wspName);
fail("Workspace creation should be denied.");
} catch (AccessDeniedException e) {
// success
}
wspName = getNewWorkspaceName(superuser.getWorkspace());
try {
Workspace wsp = getTestWorkspace();
wsp.createWorkspace(wspName, wsp.getName());
fail("Workspace creation should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testRegisterNamespace.
public void testRegisterNamespace() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_NAMESPACE_MANAGEMENT);
assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);
try {
Workspace testWsp = getTestWorkspace();
testWsp.getNamespaceRegistry().registerNamespace(getNewNamespacePrefix(testWsp), getNewNamespaceURI(testWsp));
fail("Namespace registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractWriteTest method testAccessControlRead.
public void testAccessControlRead() throws NotExecutableException, RepositoryException {
AccessControlManager testAcMgr = getTestACManager();
checkReadOnly(path);
// re-grant READ in order to have an ACL-node
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
JackrabbitAccessControlList tmpl = givePrivileges(path, privileges, getRestrictions(superuser, path));
// make sure the 'rep:policy' node has been created.
assertTrue(superuser.itemExists(tmpl.getPath() + "/rep:policy"));
Session testSession = getTestSession();
/*
Testuser must still have READ-only access only and must not be
allowed to view the acl-node that has been created.
*/
assertFalse(testAcMgr.hasPrivileges(path, privilegesFromName(Privilege.JCR_READ_ACCESS_CONTROL)));
assertFalse(testSession.itemExists(path + "/rep:policy"));
Node n = testSession.getNode(tmpl.getPath());
assertFalse(n.hasNode("rep:policy"));
try {
n.getNode("rep:policy");
fail("Accessing the rep:policy node must throw PathNotFoundException.");
} catch (PathNotFoundException e) {
// ok.
}
/* Finally the test user must not be allowed to remove the policy. */
try {
testAcMgr.removePolicy(path, new AccessControlPolicy() {
});
fail("Test user must not be allowed to remove the access control policy.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractWriteTest method testAccessControlModification.
public void testAccessControlModification() throws RepositoryException, NotExecutableException {
AccessControlManager testAcMgr = getTestACManager();
/* precondition:
testuser must have READ-only permission on test-node and below
*/
checkReadOnly(path);
Session testSession = getTestSession();
// give 'testUser' ADD_CHILD_NODES|MODIFY_PROPERTIES| REMOVE_CHILD_NODES privileges at 'path'
Privilege[] privileges = privilegesFromNames(new String[] { Privilege.JCR_ADD_CHILD_NODES, Privilege.JCR_REMOVE_CHILD_NODES, Privilege.JCR_MODIFY_PROPERTIES });
JackrabbitAccessControlList tmpl = givePrivileges(path, privileges, getRestrictions(superuser, path));
/*
testuser must not have
- permission to view AC items
- permission to modify AC items
*/
// make sure the 'rep:policy' node has been created.
assertTrue(superuser.itemExists(tmpl.getPath() + "/rep:policy"));
// the policy node however must not be visible to the test-user
assertFalse(testSession.itemExists(tmpl.getPath() + "/rep:policy"));
try {
testAcMgr.getPolicies(tmpl.getPath());
fail("test user must not have READ_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
try {
testAcMgr.getEffectivePolicies(tmpl.getPath());
fail("test user must not have READ_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
try {
testAcMgr.getEffectivePolicies(path);
fail("test user must not have READ_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
try {
testAcMgr.removePolicy(tmpl.getPath(), new AccessControlPolicy() {
});
fail("test user must not have MODIFY_AC privilege.");
} catch (AccessDeniedException e) {
// success
}
}
Aggregations