use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractVersionManagementTest method testWriteVersionStore.
public void testWriteVersionStore() throws RepositoryException, NotExecutableException {
Node trn = getTestNode();
modifyPrivileges(trn.getPath(), PrivilegeRegistry.REP_WRITE, true);
modifyPrivileges(trn.getPath(), Privilege.JCR_VERSION_MANAGEMENT, false);
Node n = createVersionableNode(testRootNode);
try {
Node n2 = trn.getNode(nodeName1);
n2.checkin();
fail("No write permission in the version storage.");
} catch (AccessDeniedException e) {
// success
log.debug(e.getMessage());
// ... but the property must not be modified nor indicating
// checkedIn status
Property p = n.getProperty("jcr:isCheckedOut");
assertFalse(p.isModified());
assertTrue(n.getProperty("jcr:isCheckedOut").getValue().getBoolean());
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testRegisterPrivilege.
public void testRegisterPrivilege() throws Exception {
assertDefaultPrivileges(PrivilegeRegistry.REP_PRIVILEGE_MANAGEMENT_NAME);
assertPermission(Permission.PRIVILEGE_MNGMT, false);
try {
Workspace testWsp = getTestWorkspace();
((JackrabbitWorkspace) testWsp).getPrivilegeManager().registerPrivilege(getNewPrivilegeName(testWsp), false, new String[0]);
fail("Privilege registration should be denied.");
} catch (AccessDeniedException e) {
// success
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractRepositoryOperationTest method testUnRegisterNodeType.
public void testUnRegisterNodeType() throws Exception {
assertDefaultPrivileges(NameConstants.JCR_NODE_TYPE_DEFINITION_MANAGEMENT);
assertPermission(Permission.NODE_TYPE_DEF_MNGMT, false);
NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
ntd.setName("testNodeType");
ntd.setMixin(true);
ntm.registerNodeType(ntd, true);
Workspace testWsp = getTestWorkspace();
try {
try {
NodeTypeManager testNtm = testWsp.getNodeTypeManager();
testNtm.unregisterNodeType(ntd.getName());
fail("Namespace unregistration should be denied.");
} catch (AccessDeniedException e) {
// success
}
try {
NodeTypeManager testNtm = testWsp.getNodeTypeManager();
testNtm.unregisterNodeTypes(new String[] { ntd.getName() });
fail("Namespace unregistration should be denied.");
} catch (AccessDeniedException e) {
// success
}
} finally {
// clean up (not supported by jackrabbit-core)
try {
ntm.unregisterNodeType(ntd.getName());
} catch (Exception e) {
// ns unregistration is not supported by jackrabbit-core.
}
}
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractNodeTypeManagementTest method testSessionImportXML.
public void testSessionImportXML() throws RepositoryException, NotExecutableException, IOException {
Session s = getTestSession();
String parentPath = childNode.getPath();
checkReadOnly(parentPath);
try {
s.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
s.save();
fail("Missing write privilege.");
} catch (AccessDeniedException e) {
// success
} finally {
s.refresh(false);
}
// with simple write privilege moving a node is not allowed.
modifyPrivileges(parentPath, Privilege.JCR_WRITE, true);
try {
s.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
s.save();
fail("Missing privilege jcr:nodeTypeManagement.");
} catch (AccessDeniedException e) {
// success
} finally {
s.refresh(false);
}
// adding jcr:nodeTypeManagement privilege will grant permission to move.
modifyPrivileges(parentPath, PrivilegeRegistry.REP_WRITE, true);
s.importXML(parentPath, getXmlForImport(), ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
s.save();
}
use of javax.jcr.AccessDeniedException in project jackrabbit by apache.
the class AbstractNodeTypeManagementTest method testSessionMove.
public void testSessionMove() throws RepositoryException, NotExecutableException {
Session s = getTestSession();
String parentPath = childNode.getParent().getPath();
String srcPath = childNode.getPath();
String destPath = parentPath + "/" + nodeName3;
checkReadOnly(parentPath);
try {
s.move(srcPath, destPath);
s.save();
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 {
s.move(srcPath, destPath);
s.save();
fail("Missing privilege jcr:nodeTypeManagement.");
} catch (AccessDeniedException e) {
// success
}
// adding jcr:nodeTypeManagement privilege will grant permission to move.
modifyPrivileges(parentPath, PrivilegeRegistry.REP_WRITE, true);
s.move(srcPath, destPath);
s.save();
}
Aggregations