jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1536653 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/user/ main/java/org/apache/jackrabbit/oak/spi/security/user/ test/java/org/apache/jackrabbit/oak/security/user/autosave/
Date Tue, 29 Oct 2013 10:56:15 GMT
Author: angela
Date: Tue Oct 29 10:56:14 2013
New Revision: 1536653

URL: http://svn.apache.org/r1536653
Log:
OAK-50 : Implement User Management

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/autosave/AutoSaveEnabledManagerTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java?rev=1536653&r1=1536652&r2=1536653&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserConfigurationImpl.java
Tue Oct 29 10:56:14 2013
@@ -27,6 +27,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.security.user.autosave.AutoSaveEnabledManager;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
@@ -34,6 +35,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
+import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.xml.ProtectedItemImporter;
 
 /**
@@ -87,6 +89,11 @@ public class UserConfigurationImpl exten
     @Nonnull
     @Override
     public UserManager getUserManager(Root root, NamePathMapper namePathMapper) {
-        return new UserManagerImpl(root, namePathMapper, getSecurityProvider());
+        UserManager umgr = new UserManagerImpl(root, namePathMapper, getSecurityProvider());
+        if (getParameters().getConfigValue(UserConstants.PARAM_SUPPORT_AUTOSAVE, false))
{
+            return new AutoSaveEnabledManager(umgr, root);
+        } else {
+            return umgr;
+        }
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java?rev=1536653&r1=1536652&r2=1536653&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
Tue Oct 29 10:56:14 2013
@@ -167,4 +167,19 @@ public interface UserConstants {
      * is used.
      */
     String PARAM_AUTHORIZABLE_ACTION_PROVIDER = "authorizableActionProvider";
+
+    /**
+     * Optional configuration parameter that might be used to get back support
+     * for the auto-save behavior which has been dropped in the default
+     * user management implementation present with OAK.
+     *
+     * <p>Note that this option has been added for those cases where API consumers
+     * rely on the implementation specific behavior present with Jackrabbit 2.x.
+     * In general using this option should not be required as the Jackrabbit
+     * User Management API expects that API consumers tests the auto-save
+     * mode is enabled. Therefore this option should be considered a temporary
+     * workaround after upgrading a repository to OAK; the affected code should
+     * be reviewed and adjusted accordingly.</p>
+     */
+    String PARAM_SUPPORT_AUTOSAVE = "supportAutoSave";
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/autosave/AutoSaveEnabledManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/autosave/AutoSaveEnabledManagerTest.java?rev=1536653&r1=1536652&r2=1536653&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/autosave/AutoSaveEnabledManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/autosave/AutoSaveEnabledManagerTest.java
Tue Oct 29 10:56:14 2013
@@ -17,15 +17,20 @@
 package org.apache.jackrabbit.oak.security.user.autosave;
 
 import java.security.Principal;
+import java.util.Collections;
 import java.util.Iterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
 
+import com.google.common.collect.ImmutableMap;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.AbstractSecurityTest;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.junit.Test;
 
@@ -37,12 +42,12 @@ import static org.junit.Assert.fail;
 
 public class AutoSaveEnabledManagerTest extends AbstractSecurityTest {
 
-    private AutoSaveEnabledManager mgr;
+    private UserManager mgr;
 
     @Override
     public void before() throws Exception {
         super.before();
-        mgr = new AutoSaveEnabledManager(getUserManager(root), root);
+        mgr = getUserManager(root);
     }
 
     @Override
@@ -61,6 +66,23 @@ public class AutoSaveEnabledManagerTest 
         super.after();
     }
 
+    @Override
+    protected ConfigurationParameters getSecurityConfigParameters() {
+        ConfigurationParameters userConfig = ConfigurationParameters.of(
+                Collections.singletonMap(UserConstants.PARAM_SUPPORT_AUTOSAVE, Boolean.TRUE));
+        return ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, userConfig));
+    }
+
+    @Test
+    public void testAutoSaveEnabled() throws RepositoryException {
+        assertTrue(mgr instanceof AutoSaveEnabledManager);
+        assertTrue(mgr.isAutoSave());
+
+        mgr.autoSave(false);
+        assertFalse(mgr.isAutoSave());
+        mgr.autoSave(true);
+    }
+
     @Test
     public void testGetAuthorizable() throws RepositoryException {
         Authorizable a = mgr.getAuthorizable(UserConstants.DEFAULT_ANONYMOUS_ID);



Mime
View raw message