Author: tomekr
Date: Wed Sep 21 09:21:03 2016
New Revision: 1761702

URL: http://svn.apache.org/viewvc?rev=1761702&view=rev
Log:
OAK-4832: Upgrade breaks if the SecurityManager section in repository.xml is 
empty

Modified:
    
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java

Modified: 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java?rev=1761702&r1=1761701&r2=1761702&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
 Wed Sep 21 09:21:03 2016
@@ -25,6 +25,7 @@ import static com.google.common.collect.
 import static com.google.common.collect.Maps.newHashMap;
 import static com.google.common.collect.Sets.newHashSet;
 import static com.google.common.collect.Sets.union;
+import static java.util.Collections.emptyMap;
 import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
 import static 
org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME;
 import static 
org.apache.jackrabbit.oak.plugins.name.Namespaces.addCustomMapping;
@@ -40,6 +41,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Calendar;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -635,13 +637,18 @@ public class RepositoryUpgrade {
                 config.getLoginModuleConfig(),
                 LoginModuleConfig.PARAM_ADMIN_ID, UserConstants.PARAM_ADMIN_ID,
                 LoginModuleConfig.PARAM_ANONYMOUS_ID, 
UserConstants.PARAM_ANONYMOUS_ID);
-        ConfigurationParameters userConfig = mapConfigurationParameters(
-                config.getSecurityManagerConfig().getUserManagerConfig(),
-                UserManagerImpl.PARAM_USERS_PATH, 
UserConstants.PARAM_USER_PATH,
-                UserManagerImpl.PARAM_GROUPS_PATH, 
UserConstants.PARAM_GROUP_PATH,
-                UserManagerImpl.PARAM_DEFAULT_DEPTH, 
UserConstants.PARAM_DEFAULT_DEPTH,
-                UserManagerImpl.PARAM_PASSWORD_HASH_ALGORITHM, 
UserConstants.PARAM_PASSWORD_HASH_ALGORITHM,
-                UserManagerImpl.PARAM_PASSWORD_HASH_ITERATIONS, 
UserConstants.PARAM_PASSWORD_HASH_ITERATIONS);
+        ConfigurationParameters userConfig;
+        if (config.getSecurityManagerConfig() == null) {
+            userConfig = ConfigurationParameters.EMPTY;
+        } else {
+            userConfig = mapConfigurationParameters(
+                    config.getSecurityManagerConfig().getUserManagerConfig(),
+                    UserManagerImpl.PARAM_USERS_PATH, 
UserConstants.PARAM_USER_PATH,
+                    UserManagerImpl.PARAM_GROUPS_PATH, 
UserConstants.PARAM_GROUP_PATH,
+                    UserManagerImpl.PARAM_DEFAULT_DEPTH, 
UserConstants.PARAM_DEFAULT_DEPTH,
+                    UserManagerImpl.PARAM_PASSWORD_HASH_ALGORITHM, 
UserConstants.PARAM_PASSWORD_HASH_ALGORITHM,
+                    UserManagerImpl.PARAM_PASSWORD_HASH_ITERATIONS, 
UserConstants.PARAM_PASSWORD_HASH_ITERATIONS);
+        }
         return ConfigurationParameters.of(ImmutableMap.of(
                 UserConfiguration.NAME,
                 ConfigurationParameters.of(loginConfig, userConfig)));


Reply via email to