use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class PrivilegeManagerImplTest method testGetRegisteredPrivileges.
public void testGetRegisteredPrivileges() throws RepositoryException {
Privilege[] registered = privilegeMgr.getRegisteredPrivileges();
Set<Privilege> set = new HashSet<Privilege>();
Privilege all = privilegeMgr.getPrivilege(Privilege.JCR_ALL);
set.add(all);
set.addAll(Arrays.asList(all.getAggregatePrivileges()));
for (Privilege p : registered) {
assertTrue(set.remove(p));
}
assertTrue(set.isEmpty());
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class PrivilegeManagerImplTest method testGetBits.
public void testGetBits() throws RepositoryException {
Privilege p1 = privilegeMgr.getPrivilege(Privilege.JCR_ADD_CHILD_NODES);
Privilege p2 = privilegeMgr.getPrivilege(Privilege.JCR_REMOVE_CHILD_NODES);
Privilege[] privs = new Privilege[] { p1, p2 };
PrivilegeBits bits = getPrivilegeManagerImpl().getBits(privs);
assertFalse(bits.isEmpty());
PrivilegeBits other = PrivilegeBits.getInstance(getPrivilegeManagerImpl().getBits(p1));
other.add(getPrivilegeManagerImpl().getBits(p2));
assertEquals(bits, other);
}
use of javax.jcr.security.Privilege in project jackrabbit by apache.
the class PrivilegeManagerImplTest method testGetBitsFromCustomAggregatePrivilege.
public void testGetBitsFromCustomAggregatePrivilege() throws RepositoryException {
Privilege p = buildCustomPrivilege("anyName", privilegeMgr.getPrivilege(Privilege.JCR_WRITE));
try {
getPrivilegeManagerImpl().getBits(p);
fail("Retrieving bits from unknown privilege should fail.");
} catch (AccessControlException e) {
// ok
}
}
use of javax.jcr.security.Privilege in project jackrabbit-oak by apache.
the class EntryTest method testUnknownPrivilege.
/**
* @since oak 1.0 ACE doesn't validate privileges.
*/
@Test
public void testUnknownPrivilege() throws Exception {
Privilege invalidPriv = new Privilege() {
public String getName() {
return "";
}
public boolean isAbstract() {
return false;
}
public boolean isAggregate() {
return false;
}
public Privilege[] getDeclaredAggregatePrivileges() {
return new Privilege[0];
}
public Privilege[] getAggregatePrivileges() {
return new Privilege[0];
}
};
Privilege[] privs = new Privilege[] { invalidPriv, acMgr.privilegeFromName(PrivilegeConstants.JCR_READ) };
ACE entry = createEntry(testPrincipal, privs, true);
assertEquals(getBitsProvider().getBits(PrivilegeConstants.JCR_READ), entry.getPrivilegeBits());
}
use of javax.jcr.security.Privilege in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method setupPolicy.
@Nonnull
private ACL setupPolicy(@Nullable String path, @Nullable Privilege... privileges) throws RepositoryException {
Privilege[] privs = (privileges == null || privileges.length == 0) ? testPrivileges : privileges;
ACL policy = getApplicablePolicy(path);
if (path == null) {
policy.addAccessControlEntry(testPrincipal, privs);
} else {
policy.addEntry(testPrincipal, privs, true, getGlobRestriction("*"));
}
acMgr.setPolicy(path, policy);
return policy;
}
Aggregations