Search in sources :

Example 1 with PrivilegeBits

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));
}
Also used : PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Nonnull(javax.annotation.Nonnull)

Example 2 with PrivilegeBits

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;
}
Also used : PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) Nonnull(javax.annotation.Nonnull)

Example 3 with PrivilegeBits

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);
}
Also used : ACE(org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE) PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) Test(org.junit.Test)

Example 4 with PrivilegeBits

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);
        }
    }
}
Also used : PrivilegeBitsProvider(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider) Tree(org.apache.jackrabbit.oak.api.Tree) PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) Test(org.junit.Test)

Example 5 with PrivilegeBits

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));
}
Also used : PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

PrivilegeBits (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)30 Test (org.junit.Test)18 Tree (org.apache.jackrabbit.oak.api.Tree)9 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)8 Nonnull (javax.annotation.Nonnull)6 PrivilegeBitsProvider (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider)6 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)3 Principal (java.security.Principal)2 Nullable (javax.annotation.Nullable)2 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)2 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)2 ACE (org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE)2 Function (com.google.common.base.Function)1 Predicate (com.google.common.base.Predicate)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Node (javax.jcr.Node)1 Privilege (javax.jcr.security.Privilege)1