use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractNodeTypeManagementTest method testWorkspaceImportXML.
public void testWorkspaceImportXML() throws RepositoryException, NotExecutableException, IOException {
Workspace wsp = getTestSession().getWorkspace();
String parentPath = childNode.getPath();
checkReadOnly(parentPath);
try {
wsp.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
fail("Missing write privilege.");
} catch (AccessDeniedException e) {
// success
}
// with simple write privilege moving a node is not allowed.
modifyPrivileges(parentPath, Privilege.JCR_WRITE, true);
try {
wsp.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
fail("Missing privilege jcr:nodeTypeManagement.");
} catch (AccessDeniedException e) {
// success
}
// adding jcr:nodeTypeManagement privilege will grant permission to move.
modifyPrivileges(parentPath, PrivilegeRegistry.REP_WRITE, true);
wsp.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testWorkspaceDeletion.
public void testWorkspaceDeletion() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_WORKSPACE_MANAGEMENT);
assertPermission(Permission.WORKSPACE_MNGMT, false);
Workspace wsp = superuser.getWorkspace();
String workspaceName = getNewWorkspaceName(wsp);
wsp.createWorkspace(workspaceName);
try {
Workspace testWsp = getTestWorkspace();
List<String> wspNames = Arrays.asList(testWsp.getAccessibleWorkspaceNames());
if (wspNames.contains(workspaceName)) {
testWsp.deleteWorkspace(workspaceName);
fail("Workspace deletion should be denied.");
}
} catch (AccessDeniedException e) {
// success
} finally {
// clean up (not supported by jackrabbit-core)
try {
superuser.getWorkspace().deleteWorkspace(workspaceName);
} catch (Exception e) {
// workspace removal is not supported by jackrabbit-core.
}
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractLockManagementTest method testReadLockContent.
public void testReadLockContent() throws RepositoryException, NotExecutableException {
Node n = createLockedNode(testRootNode);
Node childN = n.addNode(nodeName2);
modifyPrivileges(n.getPath(), Privilege.JCR_READ, false);
modifyPrivileges(childN.getPath(), Privilege.JCR_READ, true);
Node childN2 = (Node) getTestSession().getItem(childN.getPath());
try {
childN2.getLock();
fail("TestUser doesn't have permission to read the jcr:lockIsDeep property.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractLockManagementTest method testLock3.
public void testLock3() throws RepositoryException, NotExecutableException {
Node n = createLockableNode(testRootNode);
Node trn = getTestNode();
modifyPrivileges(trn.getPath(), Privilege.JCR_READ, true);
modifyPrivileges(trn.getPath(), PrivilegeRegistry.REP_WRITE, true);
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
Node n2 = trn.getNode(n.getName());
n2.lock(true, true);
Lock l = n2.getLock();
// withdraw lock-mgmt -> must not be able to refresh the lock or
// unlock the node
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, false);
try {
l.refresh();
fail("TestUser doesn't have permission to refresh the lock.");
} catch (AccessDeniedException e) {
// success
}
try {
n2.unlock();
fail("TestUser doesn't have permission to unlock the node.");
} catch (AccessDeniedException e) {
// success
}
// make sure the lock can be removed upon session.logout.
modifyPrivileges(trn.getPath(), Privilege.JCR_LOCK_MANAGEMENT, true);
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testRegisterNodeType.
public void testRegisterNodeType() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT);
assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);
Workspace testWsp = getTestWorkspace();
NodeTypeManager ntm = testWsp.getNodeTypeManager();
NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
ntd.setName("testNodeType");
ntd.setMixin(true);
try {
ntm.registerNodeType(ntd, true);
fail("Node type registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
try {
ntm.registerNodeType(ntd, false);
fail("Node type registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
NodeTypeTemplate[] ntds = new NodeTypeTemplate[2];
ntds[0] = ntd;
ntds[1] = ntm.createNodeTypeTemplate();
ntds[1].setName("anotherNodeType");
ntds[1].setDeclaredSuperTypeNames(new String[] { "nt:file" });
try {
ntm.registerNodeTypes(ntds, true);
fail("Node type registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
try {
ntm.registerNodeTypes(ntds, false);
fail("Node type registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
Aggregations