jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1414685 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: Oak.java security/privilege/PrivilegeValidator.java security/privilege/PrivilegeValidatorProvider.java spi/security/SecurityConfiguration.java
Date Wed, 28 Nov 2012 13:49:59 GMT
Author: angela
Date: Wed Nov 28 13:49:57 2012
New Revision: 1414685

URL: http://svn.apache.org/viewvc?rev=1414685&view=rev
Log:
OAK-64 : Privilege Management  (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java?rev=1414685&r1=1414684&r2=1414685&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java Wed Nov
28 13:49:57 2012
@@ -185,6 +185,7 @@ public class Oak {
     public Oak with(@Nonnull SecurityProvider securityProvider) {
         this.securityProvider = securityProvider;
         for (SecurityConfiguration sc : securityProvider.getSecurityConfigurations()) {
+            commitHooks.addAll(sc.getCommitHooks());
             validatorProviders.addAll(sc.getValidatorProviders());
             initializers.add(sc.getRepositoryInitializer());
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java?rev=1414685&r1=1414684&r2=1414685&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
Wed Nov 28 13:49:57 2012
@@ -42,14 +42,10 @@ class PrivilegeValidator implements Priv
     private final Map<String, PrivilegeDefinition> definitions;
     private final PrivilegeDefinitionReaderImpl reader;
 
-    PrivilegeValidator(Tree rootBefore) {
-        Tree privilegesBefore = null;
-        Tree system = rootBefore.getChild(JcrConstants.JCR_SYSTEM);
-        if (system != null) {
-            privilegesBefore = system.getChild(REP_PRIVILEGES);
-        }
-
-        if (privilegesBefore != null) {
+    PrivilegeValidator(NodeState before, NodeState after) {
+        NodeState privRootState = getPrivilegesRoot(before);
+        if (privRootState != null) {
+            Tree privilegesBefore = new ReadOnlyTree(privRootState);
             reader = new PrivilegeDefinitionReaderImpl(privilegesBefore);
             definitions = reader.readDefinitions();
         } else {
@@ -209,4 +205,12 @@ class PrivilegeValidator implements Priv
             throw new CommitFailedException(new IllegalStateException("Mandatory privileges
root is missing."));
         }
     }
-}
\ No newline at end of file
+
+    private static NodeState getPrivilegesRoot(NodeState rootState) {
+        NodeState system = rootState.getChildNode(JcrConstants.JCR_SYSTEM);
+        if (system != null) {
+            return system.getChildNode(REP_PRIVILEGES);
+        }
+        return null;
+    }
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorProvider.java?rev=1414685&r1=1414684&r2=1414685&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidatorProvider.java
Wed Nov 28 13:49:57 2012
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.securi
 
 import javax.annotation.Nonnull;
 
-import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.spi.commit.SubtreeValidator;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
@@ -37,6 +36,6 @@ class PrivilegeValidatorProvider impleme
     @Nonnull
     @Override
     public Validator getRootValidator(NodeState before, NodeState after) {
-        return new SubtreeValidator(new PrivilegeValidator(new ReadOnlyTree(before)), JCR_SYSTEM,
REP_PRIVILEGES);
+        return new SubtreeValidator(new PrivilegeValidator(before, after), JCR_SYSTEM, REP_PRIVILEGES);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java?rev=1414685&r1=1414684&r2=1414685&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
Wed Nov 28 13:49:57 2012
@@ -22,6 +22,8 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
 import org.apache.jackrabbit.oak.spi.commit.Observer;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer;
@@ -40,6 +42,9 @@ public interface SecurityConfiguration {
     RepositoryInitializer getRepositoryInitializer();
 
     @Nonnull
+    List<CommitHook> getCommitHooks();
+
+    @Nonnull
     List<ValidatorProvider> getValidatorProviders();
 
     @Nonnull
@@ -70,6 +75,12 @@ public interface SecurityConfiguration {
 
         @Nonnull
         @Override
+        public List<CommitHook> getCommitHooks() {
+            return Collections.<CommitHook>singletonList(new EmptyHook());
+        }
+
+        @Nonnull
+        @Override
         public List<ValidatorProvider> getValidatorProviders() {
             return Collections.emptyList();
         }



Mime
View raw message