use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class ReadTest method testAllowUserPathDenyGroupChildPath.
public void testAllowUserPathDenyGroupChildPath() throws Exception {
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
Principal group = getTestGroup().getPrincipal();
/*
allow READ privilege for testUser at 'path'
*/
givePrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
/*
deny READ privilege for group at 'childPath'
*/
withdrawPrivileges(path, group, privileges, getRestrictions(superuser, childNPath));
Session testSession = getTestSession();
assertTrue(testSession.nodeExists(childNPath));
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class ReadTest method testAllowEveryonePathDenyGroupChildPath.
public void testAllowEveryonePathDenyGroupChildPath() throws Exception {
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
Principal group = getTestGroup().getPrincipal();
Principal everyone = ((JackrabbitSession) superuser).getPrincipalManager().getEveryone();
/*
allow READ privilege for everyone at 'path'
*/
givePrivileges(path, everyone, privileges, getRestrictions(superuser, path));
/*
deny READ privilege for group at 'childNPath'
*/
withdrawPrivileges(path, group, privileges, getRestrictions(superuser, childNPath));
Session testSession = getTestSession();
assertFalse(testSession.nodeExists(childNPath));
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class ReadTest method testDenyGroupAllowUser.
public void testDenyGroupAllowUser() throws Exception {
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
Principal group = getTestGroup().getPrincipal();
/*
deny READ privilege for group at 'path'
*/
withdrawPrivileges(path, group, privileges, getRestrictions(superuser, path));
/*
allow READ privilege for testUser at 'path'
*/
givePrivileges(path, testUser.getPrincipal(), privileges, getRestrictions(superuser, path));
Session testSession = getTestSession();
assertTrue(testSession.nodeExists(path));
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class ReadTest method testRemoveMixin.
public void testRemoveMixin() throws Exception {
Node n = superuser.getNode(path);
Privilege[] privileges = privilegesFromName(Privilege.JCR_READ);
withdrawPrivileges(path, privileges, getRestrictions(superuser, path));
assertTrue(n.hasNode("rep:policy"));
assertTrue(n.isNodeType("rep:AccessControllable"));
n.removeMixin("rep:AccessControllable");
superuser.save();
assertFalse(n.hasNode("rep:policy"));
assertFalse(n.isNodeType("rep:AccessControllable"));
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class JackrabbitAccessControlListTest method testAddEntry2.
public void testAddEntry2() throws NotExecutableException, RepositoryException {
Principal princ = getValidPrincipal();
Privilege[] privs = privilegesFromName(PrivilegeRegistry.REP_WRITE);
templ.addEntry(princ, privs, true, Collections.<String, Value>emptyMap());
AccessControlEntry[] entries = templ.getAccessControlEntries();
assertTrue("GrantPrivileges was successful -> at least 1 entry for principal.", entries.length > 0);
PrivilegeBits allows = PrivilegeBits.getInstance();
for (AccessControlEntry en : entries) {
PrivilegeBits bits = privilegeMgr.getBits(en.getPrivileges());
if (en instanceof JackrabbitAccessControlEntry && ((JackrabbitAccessControlEntry) en).isAllow()) {
allows.add(bits);
}
}
assertTrue("After successfully granting WRITE, the entries must reflect this", allows.includes(privilegeMgr.getBits(privs)));
}
Aggregations