jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1374931 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: core/RootImpl.java security/privilege/PrivilegeValidator.java
Date Mon, 20 Aug 2012 07:47:49 GMT
Author: angela
Date: Mon Aug 20 07:47:48 2012
New Revision: 1374931

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

Modified:
    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/security/privilege/PrivilegeValidator.java

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=1374931&r1=1374930&r2=1374931&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
Mon Aug 20 07:47:48 2012
@@ -20,7 +20,6 @@ package org.apache.jackrabbit.oak.core;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.ChangeExtractor;
@@ -30,6 +29,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.security.authorization.PermissionValidatorProvider;
+import org.apache.jackrabbit.oak.security.privilege.PrivilegeValidatorProvider;
 import org.apache.jackrabbit.oak.security.user.UserValidatorProvider;
 import org.apache.jackrabbit.oak.spi.commit.CommitEditor;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
@@ -256,8 +256,7 @@ public class RootImpl implements Root {
         // TODO the following v-providers could be initialized at ContentRepo level
         // FIXME: use proper configuration
         providers.add(new UserValidatorProvider(valueFactory, new UserManagerConfig("admin")));
-        // FIXME: oak-core tests setup incomplete repository -> privilege validator fails.
-        // providers.add(new PrivilegeValidatorProvider(valueFactory));
+        providers.add(new PrivilegeValidatorProvider(valueFactory));
 
         return new ValidatingEditor(new CompositeValidatorProvider(providers));
     }

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=1374931&r1=1374930&r2=1374931&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
Mon Aug 20 07:47:48 2012
@@ -47,12 +47,13 @@ class PrivilegeValidator implements Priv
             privilegesBefore = system.getChild(REP_PRIVILEGES);
         }
 
-        if (privilegesBefore == null) {
-            throw new IllegalStateException("Mandatory tree /jcr:system/rep:privileges is
missing");
+        if (privilegesBefore != null) {
+            reader = new PrivilegeDefinitionReader(valueFactory, privilegesBefore);
+            definitions = PrivilegeRegistry.getAllDefinitions(reader);
+        } else {
+            reader = null;
+            definitions = null;
         }
-
-        reader = new PrivilegeDefinitionReader(valueFactory, privilegesBefore);
-        definitions = PrivilegeRegistry.getAllDefinitions(reader);
     }
 
     //----------------------------------------------------------< Validator >---
@@ -73,6 +74,8 @@ class PrivilegeValidator implements Priv
 
     @Override
     public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException
{
+        checkInitialized();
+
         // the following characteristics are expected to be validated elsewhere:
         // - permission to allow privilege registration -> permission validator.
         // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed)
@@ -169,4 +172,10 @@ class PrivilegeValidator implements Priv
             return isCircular;
         }
     }
+
+    private void checkInitialized() throws CommitFailedException {
+        if (reader == null || definitions == null) {
+            throw new CommitFailedException(new IllegalStateException("Mandatory privileges
root is missing."));
+        }
+    }
 }
\ No newline at end of file



Mime
View raw message