use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits in project jackrabbit-oak by apache.
the class PermissionStoreImpl method createPermissionEntry.
@Nonnull
private PermissionEntry createPermissionEntry(@Nonnull String path, @Nonnull Tree entryTree) {
PropertyState ps = entryTree.getProperty(REP_PRIVILEGE_BITS);
PrivilegeBits bits = (isJcrAll(ps)) ? allBits : PrivilegeBits.getInstance(ps);
boolean isAllow = TreeUtil.getBoolean(entryTree, REP_IS_ALLOW);
return new PermissionEntry(path, isAllow, Integer.parseInt(entryTree.getName()), bits, restrictionProvider.getPattern(path, entryTree));
}
use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits in project jackrabbit-oak by apache.
the class PrivilegeDefinitionWriter method next.
@Nonnull
private PrivilegeBits next() {
PrivilegeBits bits = next;
next = bits.nextBits();
return bits;
}
use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits in project jackrabbit-oak by apache.
the class EntryTest method testGetPrivilegeBits.
@Test
public void testGetPrivilegeBits() throws RepositoryException {
ACE entry = createEntry(new String[] { PrivilegeConstants.JCR_READ }, true);
PrivilegeBits bits = entry.getPrivilegeBits();
assertNotNull(bits);
assertEquals(bits, getBitsProvider().getBits(PrivilegeConstants.JCR_READ));
entry = createEntry(new String[] { PrivilegeConstants.REP_WRITE }, true);
bits = entry.getPrivilegeBits();
assertNotNull(bits);
assertEquals(bits, getBitsProvider().getBits(PrivilegeConstants.REP_WRITE));
entry = createEntry(new String[] { PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES }, true);
bits = entry.getPrivilegeBits();
assertNotNull(bits);
PrivilegeBits expected = getBitsProvider().getBits(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES);
assertEquals(expected, bits);
}
use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits in project jackrabbit-oak by apache.
the class CompositeProviderScopeTest method testGetPrivileges.
@Test
public void testGetPrivileges() throws Exception {
PrivilegeBitsProvider pbp = new PrivilegeBitsProvider(readOnlyRoot);
for (String path : defPrivileges.keySet()) {
Tree tree = readOnlyRoot.getTree(path);
Set<String> defaultPrivs = defPrivileges.get(path);
Set<String> privNames = cppTestUser.getPrivileges(tree);
if (testProvider.isSupported(path)) {
PrivilegeBits expected = pbp.getBits(defaultPrivs).modifiable().diff(denied).unmodifiable();
assertEquals(expected, pbp.getBits(privNames));
} else {
assertEquals(path, defaultPrivs, privNames);
}
}
}
use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits in project jackrabbit-oak by apache.
the class JcrAllTest method testAll.
@Test
public void testAll() {
PrivilegeBits all = bitsProvider.getBits(JCR_ALL);
assertFalse(all.isEmpty());
assertEquals(Collections.singleton(JCR_ALL), bitsProvider.getPrivilegeNames(all));
}
Aggregations