Search in sources :

Example 6 with PrivilegeBitsProvider

use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider in project jackrabbit-oak by apache.

the class L5_PrivilegeContentTest method testPrivilegeBits.

@Test
public void testPrivilegeBits() {
    Tree jcrReadTree = PrivilegeUtil.getPrivilegesTree(root).getChild(PrivilegeConstants.JCR_READ);
    Tree repWriteTree = PrivilegeUtil.getPrivilegesTree(root).getChild(PrivilegeConstants.REP_WRITE);
    PrivilegeBitsProvider provider = new PrivilegeBitsProvider(root);
    PrivilegeBits privilegeBits = provider.getBits(PrivilegeConstants.REP_WRITE, PrivilegeBits.JCR_READ);
    PrivilegeBits readBits = PrivilegeBits.getInstance(jcrReadTree);
    PrivilegeBits writeBits = PrivilegeBits.getInstance(jcrReadTree);
// EXERCISE: play with 'PrivilegeBits' methods to compare 'privilegeBits' with 'readBits' and 'writeBits'
// EXERCISE: retrieve the property that stores the long representation of each privilege above
}
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) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) L4_PrivilegesAndPermissionsTest(org.apache.jackrabbit.oak.exercise.security.authorization.permission.L4_PrivilegesAndPermissionsTest) Test(org.junit.Test) L7_PermissionContentTest(org.apache.jackrabbit.oak.exercise.security.authorization.permission.L7_PermissionContentTest)

Example 7 with PrivilegeBitsProvider

use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider in project jackrabbit-oak by apache.

the class CompositeProviderFullScopeTest method testGetPrivileges.

@Test
public void testGetPrivileges() throws Exception {
    PrivilegeBitsProvider pbp = new PrivilegeBitsProvider(readOnlyRoot);
    PrivilegeBits readNodes = pbp.getBits(REP_READ_NODES);
    Set<String> expected = ImmutableSet.of(REP_READ_NODES);
    for (String path : defPrivileges.keySet()) {
        Set<String> defaultPrivs = defPrivileges.get(path);
        Tree tree = readOnlyRoot.getTree(path);
        Set<String> privNames = cppTestUser.getPrivileges(tree);
        if (pbp.getBits(defaultPrivs).includes(readNodes)) {
            assertEquals(expected, privNames);
        } else {
            assertTrue(privNames.isEmpty());
        }
    }
}
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 8 with PrivilegeBitsProvider

use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider in project jackrabbit-oak by apache.

the class CugPermissionProviderTest method testSupportedPrivilegesForNullTree.

/**
     * @see org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider#supportedPrivileges(org.apache.jackrabbit.oak.api.Tree, org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)
     */
@Test
public void testSupportedPrivilegesForNullTree() {
    PrivilegeBits readBits = PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_READ);
    PrivilegeBits readNodeBits = PrivilegeBits.BUILT_IN.get(PrivilegeConstants.REP_READ_NODES);
    PrivilegeBits readPropBits = PrivilegeBits.BUILT_IN.get(PrivilegeConstants.REP_READ_PROPERTIES);
    PrivilegeBitsProvider provider = new PrivilegeBitsProvider(root);
    assertTrue(cugPermProvider.supportedPrivileges(null, readBits).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, readNodeBits).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, readPropBits).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, provider.getBits(PrivilegeConstants.JCR_ALL)).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, provider.getBits(PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.JCR_READ_ACCESS_CONTROL)).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, provider.getBits(PrivilegeConstants.REP_WRITE)).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, provider.getBits(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_NODE)).isEmpty());
    assertTrue(cugPermProvider.supportedPrivileges(null, provider.getBits(PrivilegeConstants.JCR_READ_ACCESS_CONTROL)).isEmpty());
}
Also used : PrivilegeBitsProvider(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider) PrivilegeBits(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits) Test(org.junit.Test)

Example 9 with PrivilegeBitsProvider

use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider in project jackrabbit-oak by apache.

the class AccessControlValidatorProvider method getRootValidator.

//--------------------------------------------------< ValidatorProvider >---
@Nonnull
@Override
public Validator getRootValidator(NodeState before, NodeState after, CommitInfo info) {
    RestrictionProvider restrictionProvider = getConfig(AuthorizationConfiguration.class).getRestrictionProvider();
    Root root = RootFactory.createReadOnlyRoot(before);
    PrivilegeManager privilegeManager = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(root, NamePathMapper.DEFAULT);
    PrivilegeBitsProvider privilegeBitsProvider = new PrivilegeBitsProvider(root);
    return new AccessControlValidator(after, privilegeManager, privilegeBitsProvider, restrictionProvider);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) Root(org.apache.jackrabbit.oak.api.Root) RestrictionProvider(org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider) PrivilegeManager(org.apache.jackrabbit.api.security.authorization.PrivilegeManager) PrivilegeBitsProvider(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider) PrivilegeConfiguration(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration) Nonnull(javax.annotation.Nonnull)

Example 10 with PrivilegeBitsProvider

use of org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider in project jackrabbit-oak by apache.

the class CompiledPermissionImpl method refresh.

//------------------------------------------------< CompiledPermissions >---
@Override
public void refresh(@Nonnull Root root, @Nonnull String workspaceName) {
    this.root = root;
    this.bitsProvider = new PrivilegeBitsProvider(root);
    this.versionManager = null;
    store.flush(root);
    userStore.flush();
    groupStore.flush();
}
Also used : PrivilegeBitsProvider(org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider)

Aggregations

PrivilegeBitsProvider (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBitsProvider)16 PrivilegeBits (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)6 Test (org.junit.Test)6 Tree (org.apache.jackrabbit.oak.api.Tree)5 Before (org.junit.Before)3 Nonnull (javax.annotation.Nonnull)2 AccessControlManager (javax.jcr.security.AccessControlManager)1 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)1 PrivilegeManager (org.apache.jackrabbit.api.security.authorization.PrivilegeManager)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 Root (org.apache.jackrabbit.oak.api.Root)1 L4_PrivilegesAndPermissionsTest (org.apache.jackrabbit.oak.exercise.security.authorization.permission.L4_PrivilegesAndPermissionsTest)1 L7_PermissionContentTest (org.apache.jackrabbit.oak.exercise.security.authorization.permission.L7_PermissionContentTest)1 TypePredicate (org.apache.jackrabbit.oak.plugins.nodetype.TypePredicate)1 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)1 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)1 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)1 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)1 PrivilegeConfiguration (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration)1 DefaultNodeStateDiff (org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff)1