jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1466488 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/core/ main/java/org/apache/jackrabbit/oak/security/authorization/permission/ test/java/org/apache/jackrabbit/oak/core/ test/java/org/apache/jackrabbit/oak...
Date Wed, 10 Apr 2013 14:02:30 GMT
Author: angela
Date: Wed Apr 10 14:02:29 2013
New Revision: 1466488

URL: http://svn.apache.org/r1466488
Log:
OAK-527: permissions (wip)

- calculate readstatus for the root tree 
- move tree type handling out of ImmuableTree
- testclass for readstatus

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ReadStatusTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableRoot.java
Wed Apr 10 14:02:29 2013
@@ -18,9 +18,6 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -32,6 +29,9 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+
 /**
  * Simple implementation of the Root interface that only supports simple read
  * operations (excluding query) based on the {@code NodeState} (or {@code ImmutableTree})
@@ -46,7 +46,7 @@ public final class ImmutableRoot impleme
         this(new ImmutableTree(rootState), workspaceName);
     }
 
-    public ImmutableRoot(@Nonnull Root root, @Nonnull ImmutableTree.TypeProvider typeProvider)
{
+    public ImmutableRoot(@Nonnull Root root, @Nonnull TreeTypeProvider typeProvider) {
         this(ImmutableTree.createFromRoot(root, typeProvider), getWorkspaceName(root));
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ImmutableTree.java
Wed Apr 10 14:02:29 2013
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.core;
 import java.util.Iterator;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 import com.google.common.base.Objects;
 import org.apache.jackrabbit.JcrConstants;
@@ -27,12 +26,8 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.commons.PathUtils;
-import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
-import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
-import org.apache.jackrabbit.oak.spi.security.Context;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.jackrabbit.oak.api.Type.STRING;
@@ -73,21 +68,21 @@ import static org.apache.jackrabbit.oak.
  *     {@link #getIdentifier()}</li>
  * </ul>
  *
- * <h3>TypeProvider</h3>
+ * <h3>TreeTypeProvider</h3>
  * For optimization purpose an Immutable tree will be associated with a
- * {@code TypeProvider} that allows for fast detection of the following types
+ * {@code TreeTypeProvider} that allows for fast detection of the following types
  * of Trees:
  *
  * <ul>
- *     <li>{@link TypeProvider#TYPE_HIDDEN}: a hidden tree whose name starts with ":".
+ *     <li>{@link TreeTypeProvider#TYPE_HIDDEN}: a hidden tree whose name starts with
":".
  *     Please note that the whole subtree of a hidden node is considered hidden.</li>
- *     <li>{@link TypeProvider#TYPE_AC}: A tree that stores access control content
+ *     <li>{@link TreeTypeProvider#TYPE_AC}: A tree that stores access control content
  *     and requires special access {@link org.apache.jackrabbit.oak.spi.security.authorization.permission.Permissions#READ_ACCESS_CONTROL
permissions}.</li>
- *     <li>{@link TypeProvider#TYPE_VERSION}: if a given tree is located within
+ *     <li>{@link TreeTypeProvider#TYPE_VERSION}: if a given tree is located within
  *     any of the version related stores defined by JSR 283. Depending on the
  *     permission evaluation implementation those items require special treatment.</li>
- *     <li>{@link TypeProvider#TYPE_DEFAULT}: the default type for trees that don't
- *     match any of the uper types.</li>
+ *     <li>{@link TreeTypeProvider#TYPE_DEFAULT}: the default type for trees that don't
+ *     match any of the upper types.</li>
  * </ul>
  *
  * <h3>Equality and hash code</h3>
@@ -102,15 +97,15 @@ import static org.apache.jackrabbit.oak.
 public final class ImmutableTree extends ReadOnlyTree {
 
     private final ParentProvider parentProvider;
-    private final TypeProvider typeProvider;
+    private final TreeTypeProvider typeProvider;
 
     private String path;
 
     public ImmutableTree(@Nonnull NodeState rootState) {
-        this(ParentProvider.ROOTPROVIDER, "", rootState, TypeProvider.EMPTY);
+        this(ParentProvider.ROOTPROVIDER, "", rootState, TreeTypeProvider.EMPTY);
     }
 
-    public ImmutableTree(@Nonnull NodeState rootState, @Nonnull TypeProvider typeProvider)
{
+    public ImmutableTree(@Nonnull NodeState rootState, @Nonnull TreeTypeProvider typeProvider)
{
         this(ParentProvider.ROOTPROVIDER, "", rootState, typeProvider);
     }
 
@@ -119,17 +114,17 @@ public final class ImmutableTree extends
     }
 
     public ImmutableTree(@Nonnull ParentProvider parentProvider, @Nonnull String name, @Nonnull
NodeState state) {
-        this(parentProvider, name, state, TypeProvider.EMPTY);
+        this(parentProvider, name, state, TreeTypeProvider.EMPTY);
     }
 
     public ImmutableTree(@Nonnull ParentProvider parentProvider, @Nonnull String name,
-                         @Nonnull NodeState state, @Nonnull TypeProvider typeProvider) {
+                         @Nonnull NodeState state, @Nonnull TreeTypeProvider typeProvider)
{
         super(null, name, state);
         this.parentProvider = checkNotNull(parentProvider);
         this.typeProvider = typeProvider;
     }
 
-    public static ImmutableTree createFromRoot(@Nonnull Root root, @Nonnull TypeProvider
typeProvider) {
+    public static ImmutableTree createFromRoot(@Nonnull Root root, @Nonnull TreeTypeProvider
typeProvider) {
         if (root instanceof RootImpl) {
             return new ImmutableTree(((RootImpl) root).getBaseState(), typeProvider);
         } else if (root instanceof ImmutableRoot) {
@@ -255,7 +250,7 @@ public final class ImmutableTree extends
         if (tree instanceof ImmutableTree) {
             return ((ImmutableTree) tree).getType();
         } else {
-            return TypeProvider.TYPE_DEFAULT;
+            return TreeTypeProvider.TYPE_DEFAULT;
         }
     }
 
@@ -273,79 +268,6 @@ public final class ImmutableTree extends
     }
 
     //--------------------------------------------------------------------------
-    // TODO
-    public interface TypeProvider {
-
-        // regular trees
-        int TYPE_DEFAULT = 1;
-        // version store(s) content
-        int TYPE_VERSION = 2;
-        // access control content
-        int TYPE_AC = 4;
-        // node type definition content
-        int TYPE_NODE_TYPE = 8;
-        // hidden trees
-        int TYPE_HIDDEN = 16;
-
-        TypeProvider EMPTY = new TypeProvider() {
-            @Override
-            public int getType(@Nullable ImmutableTree tree) {
-                return TYPE_DEFAULT;
-            }
-        };
-
-        int getType(ImmutableTree tree);
-    }
-
-    public static final class DefaultTypeProvider implements TypeProvider {
-
-        private final Context contextInfo;
-
-        public DefaultTypeProvider(@Nonnull Context contextInfo) {
-            this.contextInfo = contextInfo;
-        }
-
-        @Override
-        public int getType(ImmutableTree tree) {
-            ImmutableTree parent = tree.getParent();
-            if (parent == null) {
-                return TYPE_DEFAULT;
-            }
-
-            int type;
-            switch (parent.getType()) {
-                case TYPE_HIDDEN:
-                    type = TYPE_HIDDEN;
-                    break;
-                case TYPE_NODE_TYPE:
-                    type = TYPE_NODE_TYPE;
-                    break;
-                case TYPE_VERSION:
-                    type = TYPE_VERSION;
-                    break;
-                case TYPE_AC:
-                    type = TYPE_AC;
-                    break;
-                default:
-                    String name = tree.getName();
-                    if (NodeStateUtils.isHidden(name)) {
-                        type = TYPE_HIDDEN;
-                    } else if (NodeTypeConstants.JCR_NODE_TYPES.equals(name)) {
-                        type = TYPE_NODE_TYPE;
-                    } else if (VersionConstants.VERSION_NODE_NAMES.contains(name) ||
-                            VersionConstants.VERSION_NODE_TYPE_NAMES.contains(NodeStateUtils.getPrimaryTypeName(tree.state)))
{
-                        type = TYPE_VERSION;
-                    } else if (contextInfo.definesTree(tree)) {
-                        type = TYPE_AC;
-                    } else {
-                        type = TYPE_DEFAULT;
-                    }
-            }
-            return type;
-        }
-    }
-
-    //--------------------------------------------------------------------------
     public interface ParentProvider {
 
         ParentProvider UNSUPPORTED = new ParentProvider() {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/RootImpl.java
Wed Apr 10 14:02:29 2013
@@ -18,19 +18,12 @@
  */
 package org.apache.jackrabbit.oak.core;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-
 import javax.annotation.Nonnull;
 import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.security.auth.Subject;
@@ -70,6 +63,12 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 import org.apache.jackrabbit.oak.util.TODO;
 
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.oak.commons.PathUtils.elements;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
+
 public class RootImpl implements Root {
 
     /**
@@ -452,8 +451,8 @@ public class RootImpl implements Root {
     }
 
     @Nonnull
-    private ImmutableTree.TypeProvider getTypeProvider() {
-        return new ImmutableTree.DefaultTypeProvider(securityProvider.getAccessControlConfiguration().getContext());
+    private TreeTypeProviderImpl getTypeProvider() {
+        return new TreeTypeProviderImpl(securityProvider.getAccessControlConfiguration().getContext());
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/SecureNodeState.java
Wed Apr 10 14:02:29 2013
@@ -122,10 +122,12 @@ public class SecureNodeState extends Abs
 
     public SecureNodeState(@Nonnull NodeState rootState,
                            @Nonnull PermissionProvider permissionProvider,
-                           @Nonnull ImmutableTree.TypeProvider typeProvider) {
+                           @Nonnull TreeTypeProvider typeProvider) {
         this.state = checkNotNull(rootState);
         this.base = new ImmutableTree(rootState, typeProvider);
         this.permissionProvider = permissionProvider;
+        // calculate the readstatus for the root
+        this.readStatus = permissionProvider.getReadStatus(base, null);
     }
 
     private SecureNodeState(

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProvider.java?rev=1466488&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProvider.java
Wed Apr 10 14:02:29 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.core;
+
+import javax.annotation.Nullable;
+
+/**
+ * TreeTypeProvider... TODO
+ */
+public interface TreeTypeProvider {
+
+    // regular trees
+    int TYPE_DEFAULT = 1;
+    // version store(s) content
+    int TYPE_VERSION = 2;
+    // access control content
+    int TYPE_AC = 4;
+    // node type definition content
+    int TYPE_NODE_TYPE = 8;
+    // hidden trees
+    int TYPE_HIDDEN = 16;
+
+    TreeTypeProvider EMPTY = new TreeTypeProvider() {
+        @Override
+        public int getType(@Nullable ImmutableTree tree) {
+            return TYPE_DEFAULT;
+        }
+    };
+
+    int getType(ImmutableTree tree);
+}

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProviderImpl.java?rev=1466488&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProviderImpl.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/TreeTypeProviderImpl.java
Wed Apr 10 14:02:29 2013
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.core;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants;
+import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
+import org.apache.jackrabbit.oak.spi.security.Context;
+import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
+
+/**
+ * DefaultTreeTypeProvider... TODO
+ */
+public final class TreeTypeProviderImpl implements TreeTypeProvider {
+
+    private final Context contextInfo;
+
+    public TreeTypeProviderImpl(@Nonnull Context contextInfo) {
+        this.contextInfo = contextInfo;
+    }
+
+    @Override
+    public int getType(ImmutableTree tree) {
+        ImmutableTree parent = tree.getParent();
+        if (parent == null) {
+            return TYPE_DEFAULT;
+        }
+
+        int type;
+        switch (parent.getType()) {
+            case TYPE_HIDDEN:
+                type = TYPE_HIDDEN;
+                break;
+            case TYPE_NODE_TYPE:
+                type = TYPE_NODE_TYPE;
+                break;
+            case TYPE_VERSION:
+                type = TYPE_VERSION;
+                break;
+            case TYPE_AC:
+                type = TYPE_AC;
+                break;
+            default:
+                String name = tree.getName();
+                if (NodeStateUtils.isHidden(name)) {
+                    type = TYPE_HIDDEN;
+                } else if (NodeTypeConstants.JCR_NODE_TYPES.equals(name)) {
+                    type = TYPE_NODE_TYPE;
+                } else if (VersionConstants.VERSION_NODE_NAMES.contains(name) ||
+                        VersionConstants.VERSION_NODE_TYPE_NAMES.contains(NodeStateUtils.getPrimaryTypeName(tree.state)))
{
+                    type = TYPE_VERSION;
+                } else if (contextInfo.definesTree(tree)) {
+                    type = TYPE_AC;
+                } else {
+                    type = TYPE_DEFAULT;
+                }
+        }
+        return type;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHook.java
Wed Apr 10 14:02:29 2013
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.commons
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
 import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.TreeTypeProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlConstants;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeBits;
@@ -109,7 +110,7 @@ public class PermissionHook implements P
     }
 
     private static Tree getTree(String name, NodeState nodeState) {
-        return new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED, name, nodeState,
ImmutableTree.TypeProvider.EMPTY);
+        return new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED, name, nodeState,
TreeTypeProvider.EMPTY);
     }
 
     private static String getAccessControlledPath(Node aclNode) {
@@ -360,4 +361,4 @@ public class PermissionHook implements P
             return sb.toString();
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImpl.java
Wed Apr 10 14:02:29 2013
@@ -31,6 +31,8 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.commons.PathUtils;
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
+import org.apache.jackrabbit.oak.core.TreeTypeProvider;
+import org.apache.jackrabbit.oak.core.TreeTypeProviderImpl;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlConstants;
@@ -177,7 +179,7 @@ public class PermissionProviderImpl impl
         if (root instanceof ImmutableRoot) {
             return (ImmutableRoot) root;
         } else {
-            return new ImmutableRoot(root, new ImmutableTree.DefaultTypeProvider(acConfig.getContext()));
+            return new ImmutableRoot(root, new TreeTypeProviderImpl(acConfig.getContext()));
         }
     }
 
@@ -194,12 +196,12 @@ public class PermissionProviderImpl impl
     }
 
     private static boolean isHidden(@Nonnull Tree tree, @Nullable PropertyState propertyState)
{
-        return ImmutableTree.TypeProvider.TYPE_HIDDEN == ImmutableTree.getType(tree)
+        return TreeTypeProvider.TYPE_HIDDEN == ImmutableTree.getType(tree)
                 && (propertyState != null && NodeStateUtils.isHidden(propertyState.getName()));
     }
 
     private static boolean isAccessControlContent(@Nonnull Tree tree) {
-        return ImmutableTree.TypeProvider.TYPE_AC == ImmutableTree.getType(tree);
+        return TreeTypeProvider.TYPE_AC == ImmutableTree.getType(tree);
     }
 
     private boolean canReadAccessControlContent(@Nonnull Tree acTree, @Nullable PropertyState
acProperty) {
@@ -207,7 +209,7 @@ public class PermissionProviderImpl impl
     }
 
     private static boolean isVersionContent(@Nonnull Tree tree) {
-        return ImmutableTree.TypeProvider.TYPE_VERSION == ImmutableTree.getType(tree);
+        return TreeTypeProvider.TYPE_VERSION == ImmutableTree.getType(tree);
     }
 
     private ReadStatus getVersionContentReadStatus(@Nonnull Tree versionStoreTree, @Nullable
PropertyState property) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidator.java
Wed Apr 10 14:02:29 2013
@@ -26,6 +26,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
 import org.apache.jackrabbit.oak.core.TreeImpl;
+import org.apache.jackrabbit.oak.core.TreeTypeProvider;
 import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
 import org.apache.jackrabbit.oak.spi.commit.DefaultValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -145,7 +146,7 @@ class PermissionValidator extends Defaul
 
     private Validator checkPermissions(@Nonnull Tree tree, boolean isBefore,
                                        long defaultPermission) throws CommitFailedException
{
-        if (ImmutableTree.getType(tree) == ImmutableTree.TypeProvider.TYPE_HIDDEN) {
+        if (ImmutableTree.getType(tree) == TreeTypeProvider.TYPE_HIDDEN) {
             // ignore everything below a hidden tree
             return null;
         }
@@ -269,4 +270,4 @@ class PermissionValidator extends Defaul
         }
         return versionHistory;
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorProvider.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionValidatorProvider.java
Wed Apr 10 14:02:29 2013
@@ -25,6 +25,7 @@ import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
+import org.apache.jackrabbit.oak.core.TreeTypeProviderImpl;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.Context;
@@ -74,7 +75,7 @@ public class PermissionValidatorProvider
     }
 
     private ImmutableTree createTree(NodeState root) {
-        return new ImmutableTree(root, new ImmutableTree.DefaultTypeProvider(getAccessControlContext()));
+        return new ImmutableTree(root, new TreeTypeProviderImpl(getAccessControlContext()));
     }
 
     private PermissionProvider getPermissionProvider(NodeState before) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableRootTest.java
Wed Apr 10 14:02:29 2013
@@ -44,7 +44,7 @@ public class ImmutableRootTest extends O
         root.commit();
 
         // Acquire a fresh new root to avoid problems from lingering state
-        this.root = new ImmutableRoot(session.getLatestRoot(), ImmutableTree.TypeProvider.EMPTY);
+        this.root = new ImmutableRoot(session.getLatestRoot(), TreeTypeProvider.EMPTY);
     }
 
     // TODO: add more tests
@@ -106,4 +106,4 @@ public class ImmutableRootTest extends O
             // success
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/ImmutableTreeTest.java
Wed Apr 10 14:02:29 2013
@@ -76,7 +76,7 @@ public class ImmutableTreeTest extends O
 
     @Test
     public void testGetNodeState() {
-        ImmutableTree tree = ImmutableTree.createFromRoot(root, ImmutableTree.TypeProvider.EMPTY);
+        ImmutableTree tree = ImmutableTree.createFromRoot(root, TreeTypeProvider.EMPTY);
         assertNotNull(tree.getNodeState());
 
         for (Tree child : tree.getChildren()) {
@@ -87,23 +87,23 @@ public class ImmutableTreeTest extends O
 
     @Test
     public void testRoot() {
-        ImmutableTree tree = ImmutableTree.createFromRoot(root, ImmutableTree.TypeProvider.EMPTY);
+        ImmutableTree tree = ImmutableTree.createFromRoot(root, TreeTypeProvider.EMPTY);
         assertTrue(tree.isRoot());
         assertNull(tree.getParent());
         assertEquals("", tree.getName());
-        assertEquals(ImmutableTree.TypeProvider.TYPE_DEFAULT, tree.getType());
+        assertEquals(TreeTypeProvider.TYPE_DEFAULT, tree.getType());
     }
 
     @Test
     public void testGetParent() {
-        ImmutableTree tree = ImmutableTree.createFromRoot(root, ImmutableTree.TypeProvider.EMPTY);
+        ImmutableTree tree = ImmutableTree.createFromRoot(root, TreeTypeProvider.EMPTY);
         assertNull(tree.getParent());
 
         ImmutableTree child = tree.getChild("x");
         assertNotNull(child.getParent());
         assertEquals("/", child.getParent().getPath());
 
-        ImmutableTree disconnected = new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED,
child.getName(), child.getNodeState(), ImmutableTree.TypeProvider.EMPTY);
+        ImmutableTree disconnected = new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED,
child.getName(), child.getNodeState(), TreeTypeProvider.EMPTY);
         try {
             disconnected.getParent();
         } catch (UnsupportedOperationException e) {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java?rev=1466488&r1=1466487&r2=1466488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
Wed Apr 10 14:02:29 2013
@@ -32,6 +32,7 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.ImmutableRoot;
 import org.apache.jackrabbit.oak.core.ImmutableTree;
+import org.apache.jackrabbit.oak.core.TreeTypeProvider;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl;
@@ -308,7 +309,7 @@ public class CompiledPermissionImplTest 
     // TODO: tests for path base evaluation
 
     private CompiledPermissionImpl createPermissions(Set<Principal> principals) {
-        ImmutableTree permissionsTree = new ImmutableRoot(root, ImmutableTree.TypeProvider.EMPTY).getTree(PERMISSIONS_STORE_PATH);
+        ImmutableTree permissionsTree = new ImmutableRoot(root, TreeTypeProvider.EMPTY).getTree(PERMISSIONS_STORE_PATH);
         return new CompiledPermissionImpl(principals, permissionsTree, pbp, rp);
     }
 
@@ -383,4 +384,4 @@ public class CompiledPermissionImplTest 
             return name;
         }
     }
-}
\ No newline at end of file
+}

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ReadStatusTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ReadStatusTest.java?rev=1466488&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ReadStatusTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/ReadStatusTest.java
Wed Apr 10 14:02:29 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.security.authorization.permission;
+
+import org.apache.jackrabbit.oak.spi.security.authorization.permission.ReadStatus;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * ReadStatusTest... TODO
+ */
+public class ReadStatusTest {
+
+    @Test
+    public void testAllowAll() {
+        ReadStatus allowAll = ReadStatus.ALLOW_ALL;
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_THIS));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_CHILDREN));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_NODES));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_PROPERTIES));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_THIS_PROPERTIES));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_CHILDITEMS));
+        assertTrue(allowAll.includes(ReadStatus.ALLOW_ALL));
+    }
+}



Mime
View raw message