Author: angela
Date: Wed Dec 2 13:34:48 2015
New Revision: 1717629
URL: http://svn.apache.org/viewvc?rev=1717629&view=rev
Log:
OAK-3713 : Remove dep cycle between plugins/tree/TreeTypeProvider and
spi.security
Added:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeContext.java
- copied, changed from r1717584,
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
Modified:
jackrabbit/oak/trunk/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContext.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeTypeProvider.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/package-info.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContext.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContext.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/package-info.java
Modified:
jackrabbit/oak/trunk/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContext.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContext.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContext.java
(original)
+++
jackrabbit/oak/trunk/oak-authorization-cug/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/cug/impl/CugContext.java
Wed Dec 2 13:34:48 2015
@@ -59,4 +59,9 @@ final class CugContext implements Contex
return REP_CUG_POLICY.equals(Text.getName(path)) ||
path.endsWith(REP_CUG_POLICY + '/' + REP_PRINCIPAL_NAMES);
}
}
+
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ return false;
+ }
}
\ No newline at end of file
Copied:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeContext.java
(from r1717584,
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java)
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeContext.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeContext.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java&r1=1717584&r2=1717629&rev=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeContext.java
Wed Dec 2 13:34:48 2015
@@ -14,25 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.spi.security;
+package org.apache.jackrabbit.oak.plugins.tree;
import javax.annotation.Nonnull;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.plugins.tree.TreeLocation;
/**
- * {@code Context} represents item related information in relation to a
- * dedicated {@link
org.apache.jackrabbit.oak.spi.security.SecurityConfiguration}.
+ * {@code TreeContext} represents item related information in relation to a
+ * dedicated module.
* This information allows to determine if a given {@code Tree} or {@link
PropertyState}
- * is defined by or related to the security model provided by the
configuration.
+ * is defined by or related to the model provided by a given setup.
*/
-public interface Context {
+public interface TreeContext {
/**
- * Reveals if the specified {@code PropertyState} is defined by the
security
- * module that exposes this {@link Context} instance.
+ * Reveals if the specified {@code PropertyState} is defined by the
+ * module that exposes this {@link TreeContext} instance.
*
* @param parent The parent tree of the property state.
* @param property The {@code PropertyState} to be tested.
@@ -43,8 +42,8 @@ public interface Context {
/**
* Reveals if the specified {@code Tree} is the root of a subtree defined
by
- * the security module that exposes this {@link Context} instance. Note,
- * that in contrast to {@link
#definesTree(org.apache.jackrabbit.oak.api.Tree)}
+ * the module that exposes this {@link TreeContext} instance. Note,
+ * that in contrast to {@link #definesTree(Tree)}
* this method will only return {@code false} for any tree located in the
* subtree.
*
@@ -55,8 +54,8 @@ public interface Context {
boolean definesContextRoot(@Nonnull Tree tree);
/**
- * Reveals if the specified {@code Tree} is defined by the security
- * module that exposes this {@link Context} instance.
+ * Reveals if the specified {@code Tree} is defined by the
+ * module that exposes this {@link TreeContext} instance.
*
* @param tree The tree to be tested.
* @return {@code true} if the specified tree is related to or defined by
the
@@ -65,8 +64,8 @@ public interface Context {
boolean definesTree(@Nonnull Tree tree);
/**
- * Reveals if the specified {@code TreeLocation} is defined by the security
- * module that exposes this {@link Context} instance.
+ * Reveals if the specified {@code TreeLocation} is defined by the
+ * module that exposes this {@link TreeContext} instance.
*
* @param location The tree location to be tested.
* @return {@code true} if the specified tree location is related to or
@@ -74,33 +73,14 @@ public interface Context {
*/
boolean definesLocation(@Nonnull TreeLocation location);
- Context DEFAULT = new Default();
-
/**
- * Default implementation of the {@code Context} interface that always
returns
- * {@code false}.
+ * Reveals if the specified {@code Tree} defines repository internal
information,
+ * which is not hidden by default.
+ *
+ * @param tree The tree to be tested.
+ * @return {@code true} if the specified tree defines repository internal
information.
+ * @see org.apache.jackrabbit.oak.spi.state.NodeStateUtils#isHidden(String)
+ * @see
org.apache.jackrabbit.oak.spi.state.NodeStateUtils#isHiddenPath(String)
*/
- class Default implements Context {
-
- @Override
- public boolean definesProperty(@Nonnull Tree parent, @Nonnull
PropertyState property) {
- return false;
- }
-
- @Override
- public boolean definesContextRoot(@Nonnull Tree tree) {
- return false;
- }
-
- @Override
- public boolean definesTree(@Nonnull Tree tree) {
- return false;
- }
-
- @Override
- public boolean definesLocation(@Nonnull TreeLocation location) {
- return false;
- }
-
- }
+ boolean definesInternal(@Nonnull Tree tree);
}
\ No newline at end of file
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeTypeProvider.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeTypeProvider.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeTypeProvider.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/TreeTypeProvider.java
Wed Dec 2 13:34:48 2015
@@ -22,15 +22,13 @@ import org.apache.jackrabbit.JcrConstant
import org.apache.jackrabbit.oak.api.Tree;
import org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree;
import org.apache.jackrabbit.oak.plugins.version.VersionConstants;
-import org.apache.jackrabbit.oak.spi.security.Context;
-import
org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionConstants;
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
public final class TreeTypeProvider {
- private final Context ctx;
+ private final TreeContext ctx;
- public TreeTypeProvider(@Nonnull Context authorizationContext) {
+ public TreeTypeProvider(@Nonnull TreeContext authorizationContext) {
this.ctx = authorizationContext;
}
@@ -110,7 +108,7 @@ public final class TreeTypeProvider {
type = TreeType.HIDDEN;
} else if (VersionConstants.VERSION_STORE_ROOT_NAMES.contains(name)) {
type =
(JcrConstants.JCR_SYSTEM.equals(tree.getParent().getName())) ?
TreeType.VERSION : TreeType.DEFAULT;
- } else if (PermissionConstants.REP_PERMISSION_STORE.equals(name)) {
+ } else if (ctx.definesInternal(tree)) {
type = TreeType.INTERNAL;
} else if (ctx.definesContextRoot(tree)) {
type = TreeType.ACCESS_CONTROL;
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/package-info.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/package-info.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/package-info.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/tree/package-info.java
Wed Dec 2 13:34:48 2015
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@Version("1.2.0")
+@Version("2.0.0")
@Export(optional = "provide:=true")
package org.apache.jackrabbit.oak.plugins.tree;
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContext.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContext.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContext.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AuthorizationContext.java
Wed Dec 2 13:34:48 2015
@@ -75,6 +75,11 @@ final class AuthorizationContext impleme
}
}
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ return PermissionConstants.REP_PERMISSION_STORE.equals(tree.getName());
+ }
+
private static boolean isNodeName(@Nonnull String name) {
for (String n : NODE_NAMES) {
if (n.equals(name)) {
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContext.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContext.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContext.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeContext.java
Wed Dec 2 13:34:48 2015
@@ -57,4 +57,9 @@ final class PrivilegeContext implements
return location.getPath().startsWith(PRIVILEGES_PATH);
}
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ return false;
+ }
+
}
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserContext.java
Wed Dec 2 13:34:48 2015
@@ -87,4 +87,9 @@ final class UserContext implements Conte
}
}
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ return false;
+ }
+
}
\ No newline at end of file
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/CompositeConfiguration.java
Wed Dec 2 13:34:48 2015
@@ -285,6 +285,19 @@ public abstract class CompositeConfigura
}
return false;
}
+
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ if (delegatees == null) {
+ return defaultCtx.definesInternal(tree);
+ }
+ for (Context ctx : delegatees) {
+ if (ctx.definesInternal(tree)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
private static final class ContextFunction implements
Function<SecurityConfiguration, Context> {
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/Context.java
Wed Dec 2 13:34:48 2015
@@ -20,6 +20,7 @@ import javax.annotation.Nonnull;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.tree.TreeContext;
import org.apache.jackrabbit.oak.plugins.tree.TreeLocation;
/**
@@ -28,51 +29,7 @@ import org.apache.jackrabbit.oak.plugins
* This information allows to determine if a given {@code Tree} or {@link
PropertyState}
* is defined by or related to the security model provided by the
configuration.
*/
-public interface Context {
-
- /**
- * Reveals if the specified {@code PropertyState} is defined by the
security
- * module that exposes this {@link Context} instance.
- *
- * @param parent The parent tree of the property state.
- * @param property The {@code PropertyState} to be tested.
- * @return {@code true} if the specified property state is related to or
- * defined by the security module.
- */
- boolean definesProperty(@Nonnull Tree parent, @Nonnull PropertyState
property);
-
- /**
- * Reveals if the specified {@code Tree} is the root of a subtree defined
by
- * the security module that exposes this {@link Context} instance. Note,
- * that in contrast to {@link
#definesTree(org.apache.jackrabbit.oak.api.Tree)}
- * this method will only return {@code false} for any tree located in the
- * subtree.
- *
- * @param tree The tree to be tested.
- * @return {@code true} if the specified tree is the root of a subtree of
items
- * that are defined by the security module.
- */
- boolean definesContextRoot(@Nonnull Tree tree);
-
- /**
- * Reveals if the specified {@code Tree} is defined by the security
- * module that exposes this {@link Context} instance.
- *
- * @param tree The tree to be tested.
- * @return {@code true} if the specified tree is related to or defined by
the
- * security module.
- */
- boolean definesTree(@Nonnull Tree tree);
-
- /**
- * Reveals if the specified {@code TreeLocation} is defined by the security
- * module that exposes this {@link Context} instance.
- *
- * @param location The tree location to be tested.
- * @return {@code true} if the specified tree location is related to or
- * defined by the security module.
- */
- boolean definesLocation(@Nonnull TreeLocation location);
+public interface Context extends TreeContext {
Context DEFAULT = new Default();
@@ -102,5 +59,9 @@ public interface Context {
return false;
}
+ @Override
+ public boolean definesInternal(@Nonnull Tree tree) {
+ return false;
+ }
}
}
\ No newline at end of file
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/package-info.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/package-info.java?rev=1717629&r1=1717628&r2=1717629&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/package-info.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/package-info.java
Wed Dec 2 13:34:48 2015
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@Version("1.2.0")
+@Version("2.0.0")
@Export(optional = "provide:=true")
package org.apache.jackrabbit.oak.spi.security;