Search in sources :

Example 1 with Validator

use of org.apache.jackrabbit.oak.spi.commit.Validator in project jackrabbit-oak by apache.

the class MoveAwarePermissionValidator method visibleValidator.

private Validator visibleValidator(@Nonnull Tree source, @Nonnull Tree dest) {
    // TODO improve: avoid calculating the 'before' permissions in case the current parent permissions already point to the correct tree.
    ImmutableTree immutableTree = (ImmutableTree) moveCtx.rootBefore.getTree("/");
    TreePermission tp = getPermissionProvider().getTreePermission(immutableTree, TreePermission.EMPTY);
    for (String n : PathUtils.elements(source.getPath())) {
        immutableTree = immutableTree.getChild(n);
        tp = tp.getChildPermission(n, immutableTree.getNodeState());
    }
    Validator validator = createValidator(source, dest, tp, this);
    return new VisibleValidator(validator, true, false);
}
Also used : VisibleValidator(org.apache.jackrabbit.oak.spi.commit.VisibleValidator) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Validator(org.apache.jackrabbit.oak.spi.commit.Validator) VisibleValidator(org.apache.jackrabbit.oak.spi.commit.VisibleValidator)

Example 2 with Validator

use of org.apache.jackrabbit.oak.spi.commit.Validator in project jackrabbit-oak by apache.

the class UserValidatorTest method hiddenNodeChanged.

@Test
public void hiddenNodeChanged() throws CommitFailedException {
    UserValidatorProvider provider = new UserValidatorProvider(getConfig());
    MemoryNodeStore store = new MemoryNodeStore();
    NodeBuilder builder = store.getRoot().builder();
    builder.child("test").child(":hidden");
    NodeState root = builder.getNodeState();
    NodeBuilder test = root.builder().child("test");
    NodeBuilder hidden = test.child(":hidden");
    hidden.child("added");
    Validator validator = provider.getRootValidator(root, builder.getNodeState(), CommitInfo.EMPTY);
    Validator childValidator = validator.childNodeChanged("test", root.getChildNode("test"), test.getNodeState());
    assertNotNull(childValidator);
    Validator hiddenValidator = childValidator.childNodeChanged(":hidden", root.getChildNode("test").getChildNode(":hidden"), hidden.getNodeState());
    assertNull(hiddenValidator);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Validator(org.apache.jackrabbit.oak.spi.commit.Validator) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 3 with Validator

use of org.apache.jackrabbit.oak.spi.commit.Validator in project jackrabbit-oak by apache.

the class UserValidatorTest method hiddenNodeAdded.

@Test
public void hiddenNodeAdded() throws CommitFailedException {
    UserValidatorProvider provider = new UserValidatorProvider(getConfig());
    MemoryNodeStore store = new MemoryNodeStore();
    NodeState root = store.getRoot();
    NodeBuilder builder = root.builder();
    NodeBuilder test = builder.child("test");
    NodeBuilder hidden = test.child(":hidden");
    Validator validator = provider.getRootValidator(root, builder.getNodeState(), CommitInfo.EMPTY);
    Validator childValidator = validator.childNodeAdded("test", test.getNodeState());
    assertNotNull(childValidator);
    Validator hiddenValidator = childValidator.childNodeAdded(":hidden", hidden.getNodeState());
    assertNull(hiddenValidator);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Validator(org.apache.jackrabbit.oak.spi.commit.Validator) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 4 with Validator

use of org.apache.jackrabbit.oak.spi.commit.Validator in project jackrabbit-oak by apache.

the class AccessControlValidatorTest method hiddenNodeChanged.

@Test
public void hiddenNodeChanged() throws CommitFailedException {
    AccessControlValidatorProvider provider = new AccessControlValidatorProvider(getSecurityProvider());
    MemoryNodeStore store = new MemoryNodeStore();
    NodeBuilder builder = store.getRoot().builder();
    builder.child("test").child(":hidden");
    NodeState root = builder.getNodeState();
    NodeBuilder test = root.builder().child("test");
    NodeBuilder hidden = test.child(":hidden");
    hidden.child("added");
    Validator validator = provider.getRootValidator(root, builder.getNodeState(), CommitInfo.EMPTY);
    Validator childValidator = validator.childNodeChanged("test", root.getChildNode("test"), test.getNodeState());
    assertNotNull(childValidator);
    Validator hiddenValidator = childValidator.childNodeChanged(":hidden", root.getChildNode("test").getChildNode(":hidden"), hidden.getNodeState());
    assertNull(hiddenValidator);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Validator(org.apache.jackrabbit.oak.spi.commit.Validator) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 5 with Validator

use of org.apache.jackrabbit.oak.spi.commit.Validator in project jackrabbit-oak by apache.

the class AccessControlValidatorTest method hiddenNodeAdded.

@Test
public void hiddenNodeAdded() throws CommitFailedException {
    AccessControlValidatorProvider provider = new AccessControlValidatorProvider(getSecurityProvider());
    MemoryNodeStore store = new MemoryNodeStore();
    NodeState root = store.getRoot();
    NodeBuilder builder = root.builder();
    NodeBuilder test = builder.child("test");
    NodeBuilder hidden = test.child(":hidden");
    Validator validator = provider.getRootValidator(root, builder.getNodeState(), CommitInfo.EMPTY);
    Validator childValidator = validator.childNodeAdded("test", test.getNodeState());
    assertNotNull(childValidator);
    Validator hiddenValidator = childValidator.childNodeAdded(":hidden", hidden.getNodeState());
    assertNull(hiddenValidator);
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Validator(org.apache.jackrabbit.oak.spi.commit.Validator) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

Validator (org.apache.jackrabbit.oak.spi.commit.Validator)7 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)6 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)6 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)6 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)6 Test (org.junit.Test)6 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)1 VisibleValidator (org.apache.jackrabbit.oak.spi.commit.VisibleValidator)1 TreePermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission)1