jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1530094 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ oak-core/src/ma...
Date Mon, 07 Oct 2013 22:19:39 GMT
Author: tripod
Date: Mon Oct  7 22:19:38 2013
New Revision: 1530094

URL: http://svn.apache.org/r1530094
Log:
OAK-1082 Avoid empty instances of ConfigurationParameters

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/SecurityProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncMode.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/action/DefaultAuthorizableActionProvider.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImplTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AbstractImportTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
Mon Oct  7 22:19:38 2013
@@ -197,9 +197,9 @@ public class Activator implements Bundle
                 AccessControlConstants.PARAM_RESTRICTION_PROVIDER, restrictionProvider
         );
 
-        ConfigurationParameters securityConfig = new ConfigurationParameters(ImmutableMap.of(
-                UserConfiguration.NAME, new ConfigurationParameters(userMap),
-                AuthorizationConfiguration.NAME, new ConfigurationParameters(authorizMap)
+        ConfigurationParameters securityConfig = ConfigurationParameters.of(ImmutableMap.of(
+                UserConfiguration.NAME, ConfigurationParameters.of(userMap),
+                AuthorizationConfiguration.NAME, ConfigurationParameters.of(authorizMap)
         ));
         return securityConfig;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiSecurityProvider.java
Mon Oct  7 22:19:38 2013
@@ -78,7 +78,7 @@ public class OsgiSecurityProvider extend
         ConfigurationParameters params = config.getConfigValue(name, ConfigurationParameters.EMPTY);
         SecurityConfiguration sc = serviceMap.get(name);
         if (sc != null) {
-            return ConfigurationParameters.newInstance(params, sc.getParameters());
+            return ConfigurationParameters.of(params, sc.getParameters());
         } else {
             return params;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/SecurityProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/SecurityProviderImpl.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/SecurityProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/SecurityProviderImpl.java
Mon Oct  7 22:19:38 2013
@@ -39,7 +39,7 @@ public class SecurityProviderImpl implem
     private final ConfigurationParameters configuration;
 
     public SecurityProviderImpl() {
-        this(new ConfigurationParameters());
+        this(ConfigurationParameters.EMPTY);
     }
 
     public SecurityProviderImpl(ConfigurationParameters configuration) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImpl.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/AuthenticationConfigurationImpl.java
Mon Oct  7 22:19:38 2013
@@ -135,7 +135,7 @@ public class AuthenticationConfiguration
     @Nonnull
     @Override
     public TokenProvider getTokenProvider(Root root) {
-        ConfigurationParameters tokenOptions = getParameters().getConfigValue(PARAM_TOKEN_OPTIONS,
new ConfigurationParameters());
+        ConfigurationParameters tokenOptions = getParameters().getConfigValue(PARAM_TOKEN_OPTIONS,
ConfigurationParameters.EMPTY);
         UserConfiguration uc = getSecurityProvider().getConfiguration(UserConfiguration.class);
         return new TokenProviderImpl(root, tokenOptions, uc);
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
Mon Oct  7 22:19:38 2013
@@ -62,6 +62,6 @@ public abstract class ConfigurationBase 
     //----------------------------------------------------< SCR Integration >---
     @Activate
     protected void activate(ComponentContext context) {
-        config = ConfigurationParameters.newInstance(context.getProperties());
+        config = ConfigurationParameters.of(context.getProperties());
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationParameters.java
Mon Oct  7 22:19:38 2013
@@ -16,53 +16,86 @@
  */
 package org.apache.jackrabbit.oak.spi.security;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * ConfigurationParameters... TODO
+ * ConfigurationParameters is a convenience class that allows typed access to configuration
properties. It implements
+ * the {@link Map} interface but is immutable.
  */
-public class ConfigurationParameters {
+public class ConfigurationParameters implements Map<String, Object> {
 
+    /**
+     * internal logger
+     */
     private static final Logger log = LoggerFactory.getLogger(ConfigurationParameters.class);
 
+    /**
+     * An empty configuration parameters
+     */
     public static final ConfigurationParameters EMPTY = new ConfigurationParameters();
 
+    /**
+     * internal map of the config parameters
+     */
     private final Map<String, Object> options;
 
-    public ConfigurationParameters() {
-        this(null);
+    /**
+     * creates an empty config parameters instance.
+     * Note: the constructor is private to avoid creation of empty maps.
+     */
+    private ConfigurationParameters() {
+        this.options = Collections.emptyMap();
     }
 
-    public ConfigurationParameters(@Nullable Map<String, ?> options) {
-        this.options = (options == null) ? Collections.<String, Object>emptyMap() :
Collections.unmodifiableMap(options);
+    /**
+     * Creates an config parameter instance.
+     * Note: the constructor is private to avoid creation of empty maps.
+     * @param options the source options.
+     */
+    private ConfigurationParameters(@Nonnull Map<String, ?> options) {
+        this.options = Collections.unmodifiableMap(options);
     }
 
-    public static ConfigurationParameters newInstance(@Nonnull ConfigurationParameters...
params) {
-        Map<String, Object> m = Maps.newHashMap();
+    /**
+     * Creates a new configuration parameters instance by merging all {@code params} sequentially.
+     * I.e. property define in subsequent arguments overwrite the ones before.
+     *
+     * @param params source parameters to merge
+     * @return merged configuration parameters or {@link #EMPTY} if all source params were
empty.
+     */
+    @Nonnull
+    public static ConfigurationParameters of(@Nonnull ConfigurationParameters... params)
{
+        Map<String, Object> m = new HashMap<String, Object>();
         for (ConfigurationParameters cp : params) {
             m.putAll(cp.options);
         }
-        return new ConfigurationParameters(ImmutableMap.copyOf(m));
+        return m.isEmpty() ? EMPTY : new ConfigurationParameters(m);
     }
 
-    public static ConfigurationParameters newInstance(@Nonnull Properties properties) {
-        if (properties.isEmpty()) {
+    /**
+     * Creates new a configuration parameters instance by copying the given properties.
+     * @param properties source properties
+     * @return configuration parameters or {@link #EMPTY} if the source properties were empty.
+     */
+    @Nonnull
+    public static ConfigurationParameters of(@Nonnull Properties properties) {
+        if (properties == null || properties.isEmpty()) {
             return EMPTY;
         }
-
         Map<String, Object> options = new HashMap<String, Object>(properties.size());
         for (String name : properties.stringPropertyNames()) {
             options.put(name, properties.getProperty(name));
@@ -70,11 +103,16 @@ public class ConfigurationParameters {
         return new ConfigurationParameters(options);
     }
 
-    public static ConfigurationParameters newInstance(@Nonnull Dictionary<String, Object>
properties) {
-        if (properties.isEmpty()) {
+    /**
+     * Creates new a configuration parameters instance by copying the given properties.
+     * @param properties source properties
+     * @return configuration parameters or {@link #EMPTY} if the source properties were empty.
+     */
+    @Nonnull
+    public static ConfigurationParameters of(@Nonnull Dictionary<String, Object> properties)
{
+        if (properties == null || properties.isEmpty()) {
             return EMPTY;
         }
-
         Map<String, Object> options = new HashMap<String, Object>(properties.size());
         for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements();)
{
             String key = keys.nextElement();
@@ -84,6 +122,23 @@ public class ConfigurationParameters {
     }
 
     /**
+     * Creates new a configuration parameters instance by copying the given map.
+     * @param map source map
+     * @return configuration parameters or {@link #EMPTY} if the source map was empty.
+     */
+    @Nonnull
+    public static ConfigurationParameters of(@Nonnull Map<?, ?> map) {
+        if (map == null || map.isEmpty()) {
+            return EMPTY;
+        }
+        Map<String, Object> options = new HashMap<String, Object>(map.size());
+        for (Map.Entry<?,?> e : map.entrySet()) {
+            options.put(String.valueOf(e.getKey()), e.getValue());
+        }
+        return new ConfigurationParameters(options);
+    }
+
+    /**
      * Returns {@code true} if this instance contains a configuration entry with
      * the specified key irrespective of the defined value; {@code false} otherwise.
      *
@@ -111,6 +166,7 @@ public class ConfigurationParameters {
      *     match the type of the default value.</li>
      * </ul>
      *
+     * TODO: shouldn't a NULL configuration value be treated the same as missing one, in
respect to the default value handling? I don't think it's intuitive that NULL is returned.
      *
      * @param key The name of the configuration option.
      * @param defaultValue The default value to return if no such entry exists
@@ -128,54 +184,170 @@ public class ConfigurationParameters {
         }
     }
 
+    /**
+     * Returns the value of the configuration entry with the given {@code key}
+     * applying the following rules:
+     *
+     * <ul>
+     *     <li>If this instance doesn't contain a configuration entry with that
+     *     key, or if the entry is {@code null}, the specified {@code defaultValue} will
be returned.</li>
+     *     <li>If the configured value is not {@code null} an attempt is made to convert
the configured value to
+     *     match the type of the default value.</li>
+     * </ul>
+     *
+     * @param key The name of the configuration option.
+     * @param defaultValue The default value to return if no such entry exists
+     * or to use for conversion.
+     * @return The original or converted configuration value or {@code null}.
+     */
     @Nonnull
     public <T> T getConfigValue(@Nonnull String key, @Nonnull T defaultValue) {
-        if (options.containsKey(key)) {
-            T value = convert(options.get(key), defaultValue, null);
-            return (value == null) ? defaultValue : value;
-        } else {
+        Object property = options.get(key);
+        if (property == null) {
             return defaultValue;
+        } else {
+            return convert(property, defaultValue, null);
         }
     }
 
     //--------------------------------------------------------< private >---
     @SuppressWarnings("unchecked")
     @Nullable
-    private static <T> T convert(@Nullable Object configProperty, @Nullable T defaultValue,
@Nullable Class<T> trgtClass) {
+    private static <T> T convert(@Nullable Object configProperty, @Nullable T defaultValue,
@Nullable Class<T> targetClass) {
         if (configProperty == null) {
             return null;
         }
-
-        T value;
         String str = configProperty.toString();
-        Class targetClass;
-        if (trgtClass != null) {
-            targetClass = trgtClass;
-        } else {
-            targetClass = (defaultValue == null) ? configProperty.getClass() : defaultValue.getClass();
+        Class clazz = targetClass;
+        if (clazz == null) {
+            clazz = (defaultValue == null)
+                    ? configProperty.getClass()
+                    : defaultValue.getClass();
         }
         try {
-            if (targetClass.equals(configProperty.getClass()) || targetClass.isAssignableFrom(configProperty.getClass()))
{
-                value = (T) configProperty;
-            } else if (targetClass == String.class) {
-                value = (T) str;
-            } else if (targetClass == Integer.class) {
-                value = (T) Integer.valueOf(str);
-            } else if (targetClass == Long.class) {
-                value = (T) Long.valueOf(str);
-            } else if (targetClass == Double.class) {
-                value = (T) Double.valueOf(str);
-            } else if (targetClass == Boolean.class) {
-                value = (T) Boolean.valueOf(str);
+            if (clazz.isAssignableFrom(configProperty.getClass())) {
+                return (T) configProperty;
+            } else if (clazz == String.class) {
+                return (T) str;
+            } else if (clazz == Integer.class || clazz == int.class) {
+                return (T) Integer.valueOf(str);
+            } else if (clazz == Long.class || clazz == long.class) {
+                return (T) Long.valueOf(str);
+            } else if (clazz == Float.class || clazz == float.class) {
+                return (T) Float.valueOf(str);
+            } else if (clazz == Double.class || clazz == double.class) {
+                return (T) Double.valueOf(str);
+            } else if (clazz == Boolean.class || clazz == boolean.class) {
+                return (T) Boolean.valueOf(str);
             } else {
                 // unsupported target type
-                log.warn("Unsupported target type {} for value {}", targetClass.getName(),
str);
-                throw new IllegalArgumentException("Cannot convert config entry " + str +
" to " + targetClass.getName());
+                log.warn("Unsupported target type {} for value {}", clazz.getName(), str);
+                throw new IllegalArgumentException("Cannot convert config entry " + str +
" to " + clazz.getName());
             }
         } catch (NumberFormatException e) {
-            log.warn("Invalid value {}; cannot be parsed into {}", str, targetClass.getName());
-            throw new IllegalArgumentException("Cannot convert config entry " + str + " to
" + targetClass.getName());
+            log.warn("Invalid value {}; cannot be parsed into {}", str, clazz.getName());
+            throw new IllegalArgumentException("Cannot convert config entry " + str + " to
" + clazz.getName());
         }
-        return value;
+    }
+    //-----------------------------------------------------------------------------------<
Map interface delegation >---
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int size() {
+        return options.size();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean isEmpty() {
+        return options.isEmpty();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean containsKey(Object key) {
+        return options.containsKey(key);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean containsValue(Object value) {
+        return options.containsValue(value);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object get(Object key) {
+        return options.get(key);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object put(String key, Object value) {
+        // we rely on the immutability of the delegated map to throw the correct exceptions.
+        return options.put(key, value);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Object remove(Object key) {
+        // we rely on the immutability of the delegated map to throw the correct exceptions.
+        return options.remove(key);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void putAll(Map<? extends String, ?> m) {
+        // we rely on the immutability of the delegated map to throw the correct exceptions.
+        options.putAll(m);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void clear() {
+        // we rely on the immutability of the delegated map to throw the correct exceptions.
+        options.clear();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Set<String> keySet() {
+        return options.keySet();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Collection<Object> values() {
+        return options.values();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Set<Entry<String,Object>> entrySet() {
+        return options.entrySet();
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AbstractLoginModule.java
Mon Oct  7 22:19:38 2013
@@ -171,7 +171,7 @@ public abstract class AbstractLoginModul
         this.subject = subject;
         this.callbackHandler = callbackHandler;
         this.sharedState = sharedState;
-        this.options = new ConfigurationParameters(options);
+        this.options = ConfigurationParameters.of(options);
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncMode.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncMode.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncMode.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/external/SyncMode.java
Mon Oct  7 22:19:38 2013
@@ -71,7 +71,7 @@ public class SyncMode {
         return fromInt(mode);
     }
 
-    public static SyncMode fromStrings(String[] names) {
+    public static SyncMode fromStrings(String ... names) {
         int mode = MODE_NO_SYNC;
         for (String name : names) {
             mode |= fromString(name.trim()).mode;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/action/DefaultAuthorizableActionProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/action/DefaultAuthorizableActionProvider.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/action/DefaultAuthorizableActionProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/action/DefaultAuthorizableActionProvider.java
Mon Oct  7 22:19:38 2013
@@ -84,6 +84,6 @@ public class DefaultAuthorizableActionPr
     //----------------------------------------------------< SCR Integration >---
     @Activate
     protected void activate(ComponentContext context) {
-        config = ConfigurationParameters.newInstance(context.getProperties());
+        config = ConfigurationParameters.of(context.getProperties());
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/ConfigurationParametersTest.java
Mon Oct  7 22:19:38 2013
@@ -51,7 +51,7 @@ public class ConfigurationParametersTest
         Map<String, String> map = new HashMap<String, String>();
         map.put("key1", "v");
         map.put("key2", "v");
-        params = new ConfigurationParameters(map);
+        params = ConfigurationParameters.of(map);
         assertTrue(params.contains("key1"));
         assertTrue(params.contains("key2"));
         assertFalse(params.contains("another"));
@@ -62,7 +62,7 @@ public class ConfigurationParametersTest
     public void testGetConfigValue() {
         Map<String, String> map = new HashMap<String, String>();
         map.put("o1", "v");
-        ConfigurationParameters options = new ConfigurationParameters(map);
+        ConfigurationParameters options = ConfigurationParameters.of(map);
 
         assertEquals("v", options.getConfigValue("o1", "v2"));
         assertEquals("v2", options.getConfigValue("missing", "v2"));
@@ -72,7 +72,7 @@ public class ConfigurationParametersTest
     public void testGetNullableConfigValue() {
         Map<String, String> map = new HashMap<String, String>();
         map.put("o1", "v");
-        ConfigurationParameters options = new ConfigurationParameters(map);
+        ConfigurationParameters options = ConfigurationParameters.of(map);
 
         assertEquals("v", options.getConfigValue("o1", null, null));
         assertEquals("v", options.getConfigValue("o1", null, String.class));
@@ -91,9 +91,9 @@ public class ConfigurationParametersTest
     @Test
     public void testDefaultValue() {
         TestObject obj = new TestObject("t");
-        Integer int1000 = new Integer(1000);
+        Integer int1000 = 1000;
 
-        ConfigurationParameters options = new ConfigurationParameters();
+        ConfigurationParameters options = ConfigurationParameters.EMPTY;
 
         assertEquals(obj, options.getConfigValue("missing", obj));
         assertEquals(int1000, options.getConfigValue("missing", int1000));
@@ -114,7 +114,7 @@ public class ConfigurationParametersTest
         assertEquals(0, result.length);
         assertArrayEquals(testArray, ConfigurationParameters.EMPTY.getConfigValue("test",
testArray));
 
-        ConfigurationParameters options = new ConfigurationParameters(Collections.singletonMap("test",
testArray));
+        ConfigurationParameters options = ConfigurationParameters.of(Collections.singletonMap("test",
testArray));
         assertArrayEquals(testArray, options.getConfigValue("test", new TestObject[] {new
TestObject("s")}));
     }
 
@@ -128,7 +128,7 @@ public class ConfigurationParametersTest
         assertArrayEquals(testArray, ConfigurationParameters.EMPTY.getConfigValue("test",
testArray, null));
         assertArrayEquals(testArray, ConfigurationParameters.EMPTY.getConfigValue("test",
testArray, TestObject[].class));
 
-        ConfigurationParameters options = new ConfigurationParameters(Collections.singletonMap("test",
testArray));
+        ConfigurationParameters options = ConfigurationParameters.of(Collections.singletonMap("test",
testArray));
         assertArrayEquals(testArray, (TestObject[]) options.getConfigValue("test", null,
null));
         assertArrayEquals(testArray, options.getConfigValue("test", null, TestObject[].class));
         assertArrayEquals(testArray, options.getConfigValue("test", new TestObject[]{new
TestObject("s")}, null));
@@ -138,18 +138,20 @@ public class ConfigurationParametersTest
     @Test
     public void testConversion() {
         TestObject testObject = new TestObject("t");
-        Integer int1000 = new Integer(1000);
+        Integer int1000 = 1000;
 
         Map<String,Object> m = new HashMap<String, Object>();
         m.put("TEST", testObject);
         m.put("String", "1000");
         m.put("Int2", new Integer(1000));
         m.put("Int3", 1000);
-        ConfigurationParameters options = new ConfigurationParameters(m);
+        ConfigurationParameters options = ConfigurationParameters.of(m);
 
         assertEquals(testObject, options.getConfigValue("TEST", testObject));
         assertEquals("t", options.getConfigValue("TEST", "defaultString"));
 
+        assertTrue(1000 == options.getConfigValue("String", 10, int.class));
+        assertTrue(1000 == options.getConfigValue("String", 10));
         assertEquals(int1000, options.getConfigValue("String", new Integer(10)));
         assertEquals(new Long(1000), options.getConfigValue("String", new Long(10)));
         assertEquals("1000", options.getConfigValue("String", "10"));
@@ -171,7 +173,7 @@ public class ConfigurationParametersTest
         m.put("String", "1000");
         m.put("Int2", new Integer(1000));
         m.put("Int3", 1000);
-        ConfigurationParameters options = new ConfigurationParameters(m);
+        ConfigurationParameters options = ConfigurationParameters.of(m);
 
         assertNotNull(options.getConfigValue("TEST", null, null));
         assertNotNull(options.getConfigValue("TEST", null, TestObject.class));
@@ -212,7 +214,7 @@ public class ConfigurationParametersTest
         map.put("string", "v");
         map.put("obj", new TestObject("test"));
         map.put("int", new Integer(10));
-        ConfigurationParameters options = new ConfigurationParameters(map);
+        ConfigurationParameters options = ConfigurationParameters.of(map);
 
         Map<String, Class> impossible = new HashMap();
         impossible.put("string", TestObject.class);
@@ -234,7 +236,7 @@ public class ConfigurationParametersTest
 
     @Test
     public void testNullValue() {
-        ConfigurationParameters options = new ConfigurationParameters(Collections.singletonMap("test",
null));
+        ConfigurationParameters options = ConfigurationParameters.of(Collections.singletonMap("test",
null));
 
         assertNull(options.getConfigValue("test", null));
         assertEquals("value", options.getConfigValue("test", "value"));
@@ -245,7 +247,7 @@ public class ConfigurationParametersTest
 
     @Test
     public void testNullValue2() {
-        ConfigurationParameters options = new ConfigurationParameters(Collections.singletonMap("test",
null));
+        ConfigurationParameters options = ConfigurationParameters.of(Collections.singletonMap("test",
null));
 
         assertNull(options.getConfigValue("test", null, null));
         assertNull(options.getConfigValue("test", null, TestObject.class));

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
Mon Oct  7 22:19:38 2013
@@ -83,9 +83,9 @@ public class Jr2CompatibilityTest extend
     @Override
     protected ConfigurationParameters getSecurityConfigParameters() {
         Map<String, String> map = Collections.singletonMap(PermissionConstants.PARAM_PERMISSIONS_JR2,
PermissionConstants.VALUE_PERMISSIONS_JR2);
-        ConfigurationParameters acConfig = new ConfigurationParameters(map);
+        ConfigurationParameters acConfig = ConfigurationParameters.of(map);
 
-        return new ConfigurationParameters(ImmutableMap.of(AuthorizationConfiguration.NAME,
acConfig));
+        return ConfigurationParameters.of(ImmutableMap.of(AuthorizationConfiguration.NAME,
acConfig));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImplTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionProviderImplTest.java
Mon Oct  7 22:19:38 2013
@@ -87,9 +87,9 @@ public class PermissionProviderImplTest 
         Map<String, Object> map = new HashMap<String, Object>();
         map.put(PermissionConstants.PARAM_READ_PATHS, READ_PATHS);
         map.put(PermissionConstants.PARAM_ADMINISTRATIVE_PRINCIPALS, new String[] {ADMINISTRATOR_GROUP});
-        ConfigurationParameters acConfig = new ConfigurationParameters(map);
+        ConfigurationParameters acConfig = ConfigurationParameters.of(map);
 
-        return new ConfigurationParameters(ImmutableMap.of(AuthorizationConfiguration.NAME,
acConfig));
+        return ConfigurationParameters.of(ImmutableMap.of(AuthorizationConfiguration.NAME,
acConfig));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
Mon Oct  7 22:19:38 2013
@@ -148,7 +148,7 @@ public class UserInitializerTest extends
         userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
         userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
 
-        ConfigurationParameters params = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME,
new ConfigurationParameters(userParams)));
+        ConfigurationParameters params = ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME,
ConfigurationParameters.of(userParams)));
         SecurityProvider sp = new SecurityProviderImpl(params);
         final ContentRepository repo = new Oak().with(new InitialContent())
                 .with(new PropertyIndexEditorProvider())
@@ -199,7 +199,7 @@ public class UserInitializerTest extends
         Map<String,Object> userParams = new HashMap();
         userParams.put(UserConstants.PARAM_ANONYMOUS_ID, "");
 
-        ConfigurationParameters params = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME,
new ConfigurationParameters(userParams)));
+        ConfigurationParameters params = ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME,
ConfigurationParameters.of(userParams)));
         SecurityProvider sp = new SecurityProviderImpl(params);
         final ContentRepository repo = new Oak().with(new InitialContent())
                 .with(new PropertyIndexEditorProvider())

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderTest.java
Mon Oct  7 22:19:38 2013
@@ -62,7 +62,7 @@ public class UserProviderTest {
                 .with(new PropertyIndexEditorProvider())
                 .createRoot();
 
-        defaultConfig = new ConfigurationParameters();
+        defaultConfig = ConfigurationParameters.EMPTY;
         defaultUserPath = defaultConfig.getConfigValue(UserConstants.PARAM_USER_PATH, UserConstants.DEFAULT_USER_PATH);
         defaultGroupPath = defaultConfig.getConfigValue(UserConstants.PARAM_GROUP_PATH, UserConstants.DEFAULT_GROUP_PATH);
 
@@ -83,7 +83,7 @@ public class UserProviderTest {
     private UserProvider createUserProvider(int defaultDepth) {
         Map<String, Object> options = new HashMap<String, Object>(customOptions);
         options.put(UserConstants.PARAM_DEFAULT_DEPTH, defaultDepth);
-        return new UserProvider(root, new ConfigurationParameters(options));
+        return new UserProvider(root, ConfigurationParameters.of(options));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
Mon Oct  7 22:19:38 2013
@@ -49,8 +49,8 @@ public class AccessControlActionTest ext
         map.put(AccessControlAction.GROUP_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_READ});
         map.put(AccessControlAction.USER_PRIVILEGE_NAMES, new String[] {PrivilegeConstants.JCR_ALL});
 
-        ConfigurationParameters userConfig = new ConfigurationParameters(map);
-        return new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME, userConfig));
+        ConfigurationParameters userConfig = ConfigurationParameters.of(map);
+        return ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME, userConfig));
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
Mon Oct  7 22:19:38 2013
@@ -61,7 +61,7 @@ public class PasswordValidationActionTes
         user = (User) getUserManager(root).getAuthorizable(adminSession.getAuthInfo().getUserID());
 
         testAction.reset();
-        pwAction.init(getSecurityProvider(), new ConfigurationParameters(
+        pwAction.init(getSecurityProvider(), ConfigurationParameters.of(
                 Collections.singletonMap(PasswordValidationAction.CONSTRAINT, "^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z]).*")));
 
     }
@@ -143,7 +143,7 @@ public class PasswordValidationActionTes
         testUser = getUserManager(root).createUser("testuser", "testPw123456");
         root.commit();
         try {
-            pwAction.init(getSecurityProvider(), new ConfigurationParameters(Collections.singletonMap(PasswordValidationAction.CONSTRAINT,
"abc")));
+            pwAction.init(getSecurityProvider(), ConfigurationParameters.of(Collections.singletonMap(PasswordValidationAction.CONSTRAINT,
"abc")));
 
             String hashed = PasswordUtil.buildPasswordHash("abc");
             testUser.changePassword(hashed);
@@ -197,7 +197,7 @@ public class PasswordValidationActionTes
                     @Override
                     public ConfigurationParameters getParameters() {
                         Map<String, AuthorizableActionProvider> m = Collections.singletonMap(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER,
actionProvider);
-                        return ConfigurationParameters.newInstance(super.getParameters(),
new ConfigurationParameters(m));
+                        return ConfigurationParameters.of(super.getParameters(), ConfigurationParameters.of(m));
                     }
                 };
             } else {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AbstractImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AbstractImportTest.java?rev=1530094&r1=1530093&r2=1530094&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AbstractImportTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AbstractImportTest.java
Mon Oct  7 22:19:38 2013
@@ -70,7 +70,7 @@ public abstract class AbstractImportTest
         if (importBehavior != null) {
             Map<String, String> userParams = new HashMap();
             userParams.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, getImportBehavior());
-            ConfigurationParameters config = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME,
new ConfigurationParameters(userParams)));
+            ConfigurationParameters config = ConfigurationParameters.of(ImmutableMap.of(UserConfiguration.NAME,
ConfigurationParameters.of(userParams)));
 
             securityProvider = new SecurityProviderImpl(config);
         } else {



Mime
View raw message