jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1378974 - in /jackrabbit/oak/trunk: oak-core/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/ oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/ oak-core/src/mai...
Date Thu, 30 Aug 2012 15:01:52 GMT
Author: jukka
Date: Thu Aug 30 15:01:51 2012
New Revision: 1378974

URL: http://svn.apache.org/viewvc?rev=1378974&view=rev
Log:
OAK-50: Implement User Management

Move access control validators from Root to ContentSession. Use the JAAS doAs() mechanism
to pass the Subject and associated Principals to where they're needed.

Removed:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/TestAcContext.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTestUtils.java
Modified:
    jackrabbit/oak/trunk/oak-core/pom.xml
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.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/kernel/KernelNodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlContextImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CompositeValidatorProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingHook.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlContext.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeManagerImplTest.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java

Modified: jackrabbit/oak/trunk/oak-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-core/pom.xml Thu Aug 30 15:01:51 2012
@@ -47,12 +47,14 @@
               org.apache.jackrabbit.oak.plugins.name,
               org.apache.jackrabbit.oak.plugins.type,
               org.apache.jackrabbit.oak.plugins.value,
+              org.apache.jackrabbit.oak.spi.commit,
               org.apache.jackrabbit.oak.spi.state,
               org.apache.jackrabbit.oak.spi.security.authentication,
               org.apache.jackrabbit.oak.spi.security.principal,
               org.apache.jackrabbit.oak.spi.security.privilege,
               org.apache.jackrabbit.oak.spi.security.user,
               org.apache.jackrabbit.oak.spi.security.user.action,
+              org.apache.jackrabbit.oak.security.authorization,
               org.apache.jackrabbit.oak.security.principal,
               org.apache.jackrabbit.oak.security.privilege,
               org.apache.jackrabbit.oak.security.user

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentRepositoryImpl.java
Thu Aug 30 15:01:51 2012
@@ -95,6 +95,11 @@ public class ContentRepositoryImpl imple
                                 Collections.<ValidatorProvider> emptyList())));
     }
 
+    public ContentRepositoryImpl(
+            MicroKernel microKernel, ValidatorProvider validatorProvider) {
+        this(microKernel, null, validatorProvider);
+    }
+
     /**
      * Creates an Oak repository instance based on the given, already
      * initialized components.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/core/ContentSessionImpl.java
Thu Aug 30 15:01:51 2012
@@ -45,7 +45,6 @@ class ContentSessionImpl implements Cont
     private final String workspaceName;
     private final NodeStore store;
     private final SessionQueryEngine queryEngine;
-    private final AccessControlContext accessControlContext;
 
     public ContentSessionImpl(LoginContext loginContext, String workspaceName,
                               NodeStore store, QueryEngineImpl queryEngine,
@@ -57,8 +56,6 @@ class ContentSessionImpl implements Cont
         this.workspaceName = workspaceName;
         this.store = store;
         this.queryEngine = new SessionQueryEngineImpl(this, queryEngine);
-        this.accessControlContext = accessControlContext;
-        this.accessControlContext.initialize(getAuthInfo().getPrincipals());
     }
 
     @Nonnull
@@ -75,7 +72,7 @@ class ContentSessionImpl implements Cont
     @Nonnull
     @Override
     public Root getCurrentRoot() {
-        return new RootImpl(store, workspaceName, accessControlContext);
+        return new RootImpl(store, workspaceName, loginContext.getSubject());
     }
 
     @Override

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=1378974&r1=1378973&r2=1378974&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
Thu Aug 30 15:01:51 2012
@@ -18,25 +18,24 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
+import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
+
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.List;
 
 import javax.annotation.Nonnull;
+import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.oak.api.ChangeExtractor;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.ConflictHandler;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.TreeLocation;
-import org.apache.jackrabbit.oak.security.privilege.PrivilegeValidatorProvider;
-import org.apache.jackrabbit.oak.security.user.UserValidatorProvider;
-import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
-import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
-import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+import org.apache.jackrabbit.oak.security.authorization.AccessControlContextImpl;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.security.authorization.CompiledPermissions;
-import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
@@ -45,9 +44,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.apache.jackrabbit.oak.commons.PathUtils.getName;
-import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath;
-
 public class RootImpl implements Root {
     static final Logger log = LoggerFactory.getLogger(RootImpl.class);
 
@@ -59,10 +55,7 @@ public class RootImpl implements Root {
     /** The underlying store to which this root belongs */
     private final NodeStore store;
 
-    private final AccessControlContext accessControlContext;
-    private CompiledPermissions permissions;
-
-    private final CommitHook commitHook;
+    private final Subject subject;
 
     /** Current branch this root operates on */
     private NodeStoreBranch branch;
@@ -103,10 +96,9 @@ public class RootImpl implements Root {
      * @param accessControlContext
      */
     @SuppressWarnings("UnusedParameters")
-    public RootImpl(NodeStore store, String workspaceName, AccessControlContext accessControlContext)
{
+    public RootImpl(NodeStore store, String workspaceName, Subject subject) {
         this.store = store;
-        this.accessControlContext = accessControlContext;
-        this.commitHook = createCommitHook();
+        this.subject = subject;
         refresh();
     }
 
@@ -164,14 +156,27 @@ public class RootImpl implements Root {
     public final void refresh() {
         branch = store.branch();
         rootTree = TreeImpl.createRoot(this);
-        permissions = this.accessControlContext.getPermissions();
     }
 
     @Override
     public void commit(ConflictHandler conflictHandler) throws CommitFailedException {
         rebase(conflictHandler);
         purgePendingChanges();
-        branch.merge(commitHook);
+        CommitFailedException exception = Subject.doAs(
+                subject, new PrivilegedAction<CommitFailedException>() {
+                    @Override
+                    public CommitFailedException run() {
+                        try {
+                            branch.merge();
+                            return null;
+                        } catch (CommitFailedException e) {
+                            return e;
+                        }
+                    }
+                });
+        if (exception != null) {
+            throw exception;
+        }
         refresh();
     }
 
@@ -229,7 +234,9 @@ public class RootImpl implements Root {
     }
 
     CompiledPermissions getPermissions() {
-        return permissions;
+        AccessControlContext context = new AccessControlContextImpl();
+        context.initialize(subject.getPrincipals());
+        return context.getPermissions();
     }
 
     //------------------------------------------------------------< private >---
@@ -252,17 +259,4 @@ public class RootImpl implements Root {
         }
     }
 
-    private CommitHook createCommitHook() {
-        List<ValidatorProvider> providers = new ArrayList<ValidatorProvider>();
-
-        // TODO: refactor once permissions are read from content (make sure we read from
an up to date store)
-        providers.add(accessControlContext.getPermissionValidatorProvider());
-        providers.add(accessControlContext.getAccessControlValidatorProvider());
-        // TODO the following v-providers could be initialized at ContentRepo level
-        // FIXME: retrieve from user context
-        providers.add(new UserValidatorProvider(new UserConfig("admin")));
-        providers.add(new PrivilegeValidatorProvider());
-
-        return new ValidatingHook(new CompositeValidatorProvider(providers));
-    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreBranch.java
Thu Aug 30 15:01:51 2012
@@ -20,7 +20,6 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.mk.api.MicroKernelException;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
-import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStoreBranch;
 
@@ -123,11 +122,9 @@ class KernelNodeStoreBranch implements N
     }
 
     @Override
-    public NodeState merge(CommitHook hook) throws CommitFailedException {
+    public NodeState merge() throws CommitFailedException {
         NodeState oldRoot = base;
-        CommitHook commitHook = hook == null
-                ? store.getHook()
-                : new CompositeHook(store.getHook(), hook);
+        CommitHook commitHook = store.getHook();
         NodeState toCommit = commitHook.processCommit(store, oldRoot, currentRoot);
         setRoot(toCommit);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/memory/MemoryNodeStore.java
Thu Aug 30 15:01:51 2012
@@ -20,7 +20,6 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
-import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -82,7 +81,7 @@ public class MemoryNodeStore implements 
         }
 
         @Override
-        public NodeState merge(CommitHook hook) throws CommitFailedException {
+        public NodeState merge() throws CommitFailedException {
             while (!MemoryNodeStore.this.root.compareAndSet(base, root)) {
                 // TODO: rebase();
                 throw new UnsupportedOperationException();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlContextImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlContextImpl.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlContextImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlContextImpl.java
Thu Aug 30 15:01:51 2012
@@ -21,7 +21,6 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
-import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.CompiledPermissions;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
@@ -31,7 +30,6 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public class AccessControlContextImpl implements AccessControlContext {
 
-    private static final CompiledPermissions NO_PERMISSIONS = new SimplePermissions(false);
     private static final CompiledPermissions ADMIN_PERMISSIONS = new SimplePermissions(true);
 
     private Set<Principal> principals;
@@ -44,9 +42,7 @@ public class AccessControlContextImpl im
 
     @Override
     public CompiledPermissions getPermissions() {
-        if (principals == null || principals.isEmpty()) {
-            return NO_PERMISSIONS;
-        } else if (principals.contains(AdminPrincipal.INSTANCE)) {
+        if (principals.contains(AdminPrincipal.INSTANCE)) {
             return ADMIN_PERMISSIONS;
         } else {
             // TODO: replace with permissions based on ac evaluation
@@ -54,16 +50,6 @@ public class AccessControlContextImpl im
         }
     }
 
-    @Override
-    public ValidatorProvider getPermissionValidatorProvider() {
-        return new PermissionValidatorProvider(this);
-    }
-
-    @Override
-    public ValidatorProvider getAccessControlValidatorProvider() {
-        return new AccessControlValidatorProvider(this);
-    }
-
     //--------------------------------------------------------------------------
     /**
      * Trivial implementation of the {@code CompiledPermissions} interface that

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorProvider.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorProvider.java
Thu Aug 30 15:01:51 2012
@@ -20,24 +20,12 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.spi.commit.Validator;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * AccessControlValidatorProvider... TODO
  */
-class AccessControlValidatorProvider implements ValidatorProvider {
-
-    /**
-     * logger instance
-     */
-    private static final Logger log = LoggerFactory.getLogger(AccessControlValidatorProvider.class);
-
-    public AccessControlValidatorProvider(AccessControlContext accessControlContext) {
-        // TODO
-    }
+public class AccessControlValidatorProvider implements ValidatorProvider {
 
     @Nonnull
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/PermissionValidatorProvider.java
Thu Aug 30 15:01:51 2012
@@ -16,7 +16,12 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
 
+import java.security.AccessController;
+import java.security.Principal;
+import java.util.Set;
+
 import javax.annotation.Nonnull;
+import javax.security.auth.Subject;
 
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -25,23 +30,27 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 
+import com.google.common.collect.ImmutableSet;
+
 /**
  * PermissionValidatorProvider... TODO
  */
-class PermissionValidatorProvider implements ValidatorProvider {
+public class PermissionValidatorProvider implements ValidatorProvider {
 
-    private final AccessControlContext accessControlContext;
-
-    public PermissionValidatorProvider(AccessControlContext accessControlContext) {
-        this.accessControlContext = accessControlContext;
-    }
-
-    //--------------------------------------------------< ValidatorProvider >---
     @Nonnull
     @Override
     public Validator getRootValidator(NodeState before, NodeState after) {
+        Set<Principal> principals = ImmutableSet.of();
+        Subject subject = Subject.getSubject(AccessController.getContext());
+        if (subject != null) {
+            principals = subject.getPrincipals();
+        }
+
+        AccessControlContext context = new AccessControlContextImpl();
+        context.initialize(principals);
+
         NodeUtil rootBefore = new NodeUtil(new ReadOnlyTree(before));
         NodeUtil rootAfter = new NodeUtil(new ReadOnlyTree(after));
-        return new PermissionValidator(accessControlContext.getPermissions(), rootBefore,
rootAfter);
+        return new PermissionValidator(context.getPermissions(), rootBefore, rootAfter);
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CompositeValidatorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CompositeValidatorProvider.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CompositeValidatorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/CompositeValidatorProvider.java
Thu Aug 30 15:01:51 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.spi.co
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -33,6 +34,10 @@ public class CompositeValidatorProvider 
         this.providers = providers;
     }
 
+    public CompositeValidatorProvider(ValidatorProvider... providers) {
+        this(Arrays.asList(providers));
+    }
+
     @Override
     public Validator getRootValidator(NodeState before, NodeState after) {
         List<Validator> rootValidators = new ArrayList<Validator>(providers.size());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingHook.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/commit/ValidatingHook.java
Thu Aug 30 15:01:51 2012
@@ -42,6 +42,10 @@ public class ValidatingHook implements C
         this.validatorProvider = validatorProvider;
     }
 
+    public ValidatingHook(ValidatorProvider... providers) {
+        this(new CompositeValidatorProvider(providers));
+    }
+
     @Override
     public NodeState processCommit(
             NodeStore store, NodeState before, NodeState after)

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlContext.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlContext.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlContext.java
Thu Aug 30 15:01:51 2012
@@ -19,8 +19,6 @@ package org.apache.jackrabbit.oak.spi.se
 import java.security.Principal;
 import java.util.Set;
 
-import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
-
 /**
  * PermissionProvider... TODO
  */
@@ -31,7 +29,4 @@ public interface AccessControlContext {
     // TODO define how permissions eval is bound to a particular revision/branch. (passing
Tree?)
     CompiledPermissions getPermissions();
 
-    ValidatorProvider getPermissionValidatorProvider();
-
-    ValidatorProvider getAccessControlValidatorProvider();
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/state/NodeStoreBranch.java
Thu Aug 30 15:01:51 2012
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.spi.st
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 
 public interface NodeStoreBranch {
 
@@ -66,13 +65,12 @@ public interface NodeStoreBranch {
 
     /**
      * Merges the changes in this branch to the main content tree.
-     * @param hook  commit hook to apply
-     * @return the node state resulting from the merge.
      *
+     * @return the node state resulting from the merge.
      * @throws CommitFailedException if the merge failed
      */
     @Nonnull
-    NodeState merge(CommitHook hook) throws CommitFailedException;
+    NodeState merge() throws CommitFailedException;
 
 }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/AbstractCoreTest.java
Thu Aug 30 15:01:51 2012
@@ -16,11 +16,12 @@
  */
 package org.apache.jackrabbit.oak.core;
 
+import javax.security.auth.Subject;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.CoreValueFactory;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
-import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlContext;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.junit.Before;
 import org.slf4j.Logger;
@@ -39,7 +40,6 @@ public abstract class AbstractCoreTest {
     // TODO: use regular oak-repo setup
     protected KernelNodeStore store;
     protected CoreValueFactory valueFactory;
-    protected AccessControlContext acContext;
 
     protected NodeState state;
 
@@ -48,14 +48,12 @@ public abstract class AbstractCoreTest {
         MicroKernel microKernel = new MicroKernelImpl();
         store = new KernelNodeStore(microKernel);
         valueFactory = store.getValueFactory();
-        acContext = new TestAcContext();
-
         state = createInitialState(microKernel);
     }
 
     protected abstract NodeState createInitialState(MicroKernel microKernel);
 
     protected RootImpl createRootImpl(String workspaceName) {
-        return new RootImpl(store, workspaceName, acContext);
+        return new RootImpl(store, workspaceName, new Subject());
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/core/RootImplFuzzIT.java
Thu Aug 30 15:01:51 2012
@@ -21,6 +21,8 @@ package org.apache.jackrabbit.oak.core;
 import java.util.Iterator;
 import java.util.Random;
 
+import javax.security.auth.Subject;
+
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.CoreValue;
@@ -78,12 +80,12 @@ public class RootImplFuzzIT {
         store1 = new KernelNodeStore(mk1);
         vf = store1.getValueFactory();
         mk1.commit("", "+\"/root\":{}", mk1.getHeadRevision(), "");
-        root1 = new RootImpl(store1, null, new TestAcContext());
+        root1 = new RootImpl(store1, null, new Subject());
 
         MicroKernel mk2 = new MicroKernelImpl("./target/mk2/" + random.nextInt());
         store2 = new KernelNodeStore(mk2);
         mk2.commit("", "+\"/root\":{}", mk2.getHeadRevision(), "");
-        root2 = new RootImpl(store2, null, new TestAcContext());
+        root2 = new RootImpl(store2, null, new Subject());
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/kernel/KernelNodeStoreTest.java
Thu Aug 30 15:01:51 2012
@@ -24,7 +24,6 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.api.CoreValue;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeState;
 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.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
@@ -105,7 +104,7 @@ public class KernelNodeStoreTest {
         assertNull(testState.getChildNode("newNode"));
         assertNotNull(testState.getChildNode("x"));
 
-        branch.merge(EmptyHook.INSTANCE);
+        branch.merge();
 
         // Assert changes are present in the trunk
         testState = store.getRoot().getChildNode("test");
@@ -140,7 +139,7 @@ public class KernelNodeStoreTest {
 
         NodeStoreBranch branch = store.branch();
         branch.setRoot(newRoot);
-        branch.merge(EmptyHook.INSTANCE);
+        branch.merge();
         store.getRoot(); // triggers the observer
 
         NodeState before = states[0];
@@ -183,7 +182,7 @@ public class KernelNodeStoreTest {
 
         NodeStoreBranch branch = store.branch();
         branch.setRoot(newRoot);
-        branch.merge(EmptyHook.INSTANCE);
+        branch.merge();
 
         NodeState test = store.getRoot().getChildNode("test");
         assertNotNull(test.getChildNode("newNode"));

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneEditorTest.java
Thu Aug 30 15:01:51 2012
@@ -16,12 +16,13 @@
  */
 package org.apache.jackrabbit.oak.plugins.lucene;
 
+import javax.security.auth.Subject;
+
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.core.DefaultConflictHandler;
 import org.apache.jackrabbit.oak.core.RootImpl;
-import org.apache.jackrabbit.oak.core.TestAcContext;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
 import org.apache.jackrabbit.oak.plugins.memory.MemoryValueFactory;
 import org.apache.jackrabbit.oak.query.ast.Operator;
@@ -48,7 +49,7 @@ public class LuceneEditorTest {
 
         KernelNodeStore store = new KernelNodeStore(new MicroKernelImpl());
         store.setHook(new LuceneEditor(testID));
-        Root root = new RootImpl(store, "", new TestAcContext());
+        Root root = new RootImpl(store, null, new Subject());
         Tree tree = root.getTree("/");
 
         tree.setProperty("foo", MemoryValueFactory.INSTANCE.createValue("bar"));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/RepositoryImpl.java
Thu Aug 30 15:01:51 2012
@@ -27,9 +27,22 @@ import javax.jcr.Value;
 import javax.security.auth.login.LoginException;
 
 import org.apache.jackrabbit.commons.SimpleValueFactory;
+import org.apache.jackrabbit.mk.api.MicroKernel;
+import org.apache.jackrabbit.mk.core.MicroKernelImpl;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
+import org.apache.jackrabbit.oak.plugins.name.NameValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.name.NamespaceValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
+import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.security.authorization.AccessControlValidatorProvider;
+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.CompositeValidatorProvider;
+import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,6 +56,18 @@ public class RepositoryImpl implements R
      */
     private static final Logger log = LoggerFactory.getLogger(RepositoryImpl.class);
 
+    private static final ValidatorProvider DEFAULT_VALIDATOR =
+            new CompositeValidatorProvider(
+                    new NameValidatorProvider(),
+                    new NamespaceValidatorProvider(),
+                    new TypeValidatorProvider(),
+                    new ConflictValidatorProvider(),
+                    new PermissionValidatorProvider(),
+                    new AccessControlValidatorProvider(),
+                    // FIXME: retrieve from user context
+                    new UserValidatorProvider(new UserConfig("admin")),
+                    new PrivilegeValidatorProvider());
+
     private final Descriptors descriptors = new Descriptors(new SimpleValueFactory());
     private final ContentRepository contentRepository;
 
@@ -55,6 +80,11 @@ public class RepositoryImpl implements R
         this.executor = executor;
     }
 
+    public RepositoryImpl(
+            MicroKernel kernel, ScheduledExecutorService executor) {
+        this(new ContentRepositoryImpl(kernel, DEFAULT_VALIDATOR), executor);
+    }
+
     /**
      * Utility constructor that creates a new in-memory repository for use
      * mostly in test cases. The executor service is initialized with an
@@ -63,7 +93,7 @@ public class RepositoryImpl implements R
      * if such features are needed.
      */
     public RepositoryImpl() {
-        this(new ContentRepositoryImpl(), Executors.newScheduledThreadPool(0));
+        this(new MicroKernelImpl(), Executors.newScheduledThreadPool(0));
     }
 
     //---------------------------------------------------------< Repository >---

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
Thu Aug 30 15:01:51 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.oak.jcr;
 
-import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 
 import javax.jcr.GuestCredentials;
@@ -26,11 +25,8 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.junit.After;
 
-import static org.apache.jackrabbit.oak.jcr.RepositoryTestUtils.buildDefaultCommitHook;
-
 /**
  * Abstract base class for repository tests providing methods for accessing
  * the repository, a session and nodes and properties from that session.
@@ -40,7 +36,7 @@ import static org.apache.jackrabbit.oak.
  */
 public abstract class AbstractRepositoryTest {
 
-    private ScheduledExecutorService executor = null;
+    protected ScheduledExecutorService executor = null;
 
     private Repository repository = null;
     private Session adminSession = null;
@@ -63,10 +59,11 @@ public abstract class AbstractRepository
 
     protected Repository getRepository() throws RepositoryException {
         if (repository == null) {
-            executor = Executors.newScheduledThreadPool(1);
-            repository = new RepositoryImpl(new ContentRepositoryImpl(
-                    new MicroKernelImpl(), null, buildDefaultCommitHook()),
-                    executor);
+            if (executor != null) {
+                repository = new RepositoryImpl(new MicroKernelImpl(), executor);
+            } else {
+                repository = new RepositoryImpl();
+            }
         }
         return repository;
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Thu Aug 30 15:01:51 2012
@@ -28,15 +28,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
 
-import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
 
-import static org.apache.jackrabbit.oak.jcr.RepositoryTestUtils.buildDefaultCommitHook;
-
 public class OakRepositoryStub extends RepositoryStub {
 
     private final Repository repository;
@@ -51,9 +46,10 @@ public class OakRepositoryStub extends R
     public OakRepositoryStub(Properties settings) throws RepositoryException, IOException
{
         super(settings);
 
-        MicroKernel microkernel = new MicroKernelImpl("target/mk-tck-" + System.currentTimeMillis());
-        ContentRepository contentRepository = new ContentRepositoryImpl(microkernel, null,
buildDefaultCommitHook());
-        repository = new RepositoryImpl(contentRepository, Executors.newScheduledThreadPool(1));
+        String dir = "target/mk-tck-" + System.currentTimeMillis();
+        repository = new RepositoryImpl(
+                new MicroKernelImpl(dir),
+                Executors.newScheduledThreadPool(1));
 
         Session session = repository.login(superuser);
         try {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Thu Aug 30 15:01:51 2012
@@ -80,6 +80,8 @@ public class RepositoryTest extends Abst
 
     @Before
     public void setup() throws RepositoryException {
+        executor = Executors.newScheduledThreadPool(1);
+
         Session session = getAdminSession();
         ValueFactory valueFactory = session.getValueFactory();
         Node root = session.getRootNode();

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeManagerImplTest.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeManagerImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/privilege/PrivilegeManagerImplTest.java
Thu Aug 30 15:01:51 2012
@@ -16,6 +16,12 @@
  */
 package org.apache.jackrabbit.oak.jcr.security.privilege;
 
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -24,7 +30,6 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.Executors;
 
 import javax.jcr.AccessDeniedException;
 import javax.jcr.Credentials;
@@ -39,21 +44,12 @@ import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
-import org.apache.jackrabbit.mk.core.MicroKernelImpl;
-import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeConstants;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertNotNull;
-import static junit.framework.Assert.assertTrue;
-import static org.apache.jackrabbit.oak.jcr.RepositoryTestUtils.buildDefaultCommitHook;
-import static org.junit.Assert.fail;
-
 /**
  * PrivilegeManagerTest...
  *
@@ -69,15 +65,17 @@ public class PrivilegeManagerImplTest im
     private PrivilegeManager privilegeManager;
 
     @Before
-    public void setUp() throws Exception {
-        ContentRepository contentRepository = new ContentRepositoryImpl(
-                new MicroKernelImpl(), null, buildDefaultCommitHook());
-        repository = new RepositoryImpl(
-                contentRepository, Executors.newScheduledThreadPool(1));
-
+    public void setUp() throws RepositoryException {
+        repository = new RepositoryImpl();
         privilegeManager = getPrivilegeManager(ADMIN);
     }
 
+    @After
+    public void tearDown() {
+        privilegeManager = null;
+        repository = null;
+    }
+
     private PrivilegeManager getPrivilegeManager(Credentials credentials)
             throws RepositoryException {
         Workspace workspace = repository.login(credentials).getWorkspace();

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java?rev=1378974&r1=1378973&r2=1378974&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/Main.java Thu
Aug 30 15:01:51 2012
@@ -36,11 +36,16 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.type.DefaultTypeEditor;
 import org.apache.jackrabbit.oak.plugins.type.TypeValidatorProvider;
 import org.apache.jackrabbit.oak.plugins.value.ConflictValidatorProvider;
+import org.apache.jackrabbit.oak.security.authorization.AccessControlValidatorProvider;
+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.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.CompositeValidatorProvider;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.webdav.jcr.JCRWebdavServerServlet;
 import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
 import org.eclipse.jetty.server.Server;
@@ -207,6 +212,11 @@ public class Main {
             providers.add(new NamespaceValidatorProvider());
             providers.add(new TypeValidatorProvider());
             providers.add(new ConflictValidatorProvider());
+            providers.add(new PermissionValidatorProvider());
+            providers.add(new AccessControlValidatorProvider());
+            // FIXME: retrieve from user context
+            providers.add(new UserValidatorProvider(new UserConfig("admin")));
+            providers.add(new PrivilegeValidatorProvider());
             return new CompositeValidatorProvider(providers);
         }
 



Mime
View raw message