jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1490214 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorizatio...
Date Thu, 06 Jun 2013 09:43:41 GMT
Author: angela
Date: Thu Jun  6 09:43:40 2013
New Revision: 1490214

URL: http://svn.apache.org/r1490214
Log:
OAK-754 : Pluggable Security Setup (WIP)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
Modified:
    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/security/authorization/AccessControlConfigurationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImpl.java
    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/ConfigurationParameters.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthenticationConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeConfiguration.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfiguration.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/spi/security/user/action/AccessControlActionTest.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/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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -49,7 +49,7 @@ public class SecurityProviderImpl implem
     @Nonnull
     @Override
     public ConfigurationParameters getParameters(String name) {
-        return (name == null) ? configuration : configuration.getConfigValue(name, new ConfigurationParameters());
+        return (name == null) ? configuration : configuration.getConfigValue(name, ConfigurationParameters.EMPTY);
     }
 
     @Nonnull

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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -21,12 +21,12 @@ import javax.security.auth.login.Configu
 
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.Root;
-import org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil;
 import org.apache.jackrabbit.oak.security.authentication.token.TokenProviderImpl;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
-import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration;
+import org.apache.jackrabbit.oak.spi.security.authentication.ConfigurationUtil;
 import org.apache.jackrabbit.oak.spi.security.authentication.LoginContextProvider;
 import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
@@ -49,18 +49,22 @@ import org.slf4j.LoggerFactory;
  * </ul>
  *
  */
-public class AuthenticationConfigurationImpl extends SecurityConfiguration.Default implements
AuthenticationConfiguration {
+public class AuthenticationConfigurationImpl extends ConfigurationBase implements AuthenticationConfiguration
{
 
     private static final Logger log = LoggerFactory.getLogger(AuthenticationConfigurationImpl.class);
 
-    private final SecurityProvider securityProvider;
-    private final ConfigurationParameters config;
-
     public AuthenticationConfigurationImpl(SecurityProvider securityProvider) {
-        this.securityProvider = securityProvider;
-        this.config = securityProvider.getParameters(PARAM_AUTHENTICATION_OPTIONS);
+        super(securityProvider);
+    }
+
+    //----------------------------------------------< SecurityConfiguration >---
+    @Nonnull
+    @Override
+    public String getName() {
+        return NAME;
     }
 
+    //----------------------------------------< AuthenticationConfiguration >---
     /**
      * Create a {@code LoginContextProvider} using standard
      * {@link javax.security.auth.login.Configuration#getConfiguration() JAAS}
@@ -88,7 +92,7 @@ public class AuthenticationConfiguration
     @Nonnull
     @Override
     public LoginContextProvider getLoginContextProvider(ContentRepository contentRepository)
{
-        String appName = config.getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
+        String appName = getParameters().getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
         Configuration loginConfig = null;
         try {
             loginConfig = Configuration.getConfiguration();
@@ -101,9 +105,9 @@ public class AuthenticationConfiguration
         }
         if (loginConfig == null) {
             log.debug("No login configuration available for {}; using default", appName);
-            loginConfig = ConfigurationUtil.getDefaultConfiguration(config);
+            loginConfig = ConfigurationUtil.getDefaultConfiguration(getParameters());
         }
-        return new LoginContextProviderImpl(appName, loginConfig, contentRepository, securityProvider);
+        return new LoginContextProviderImpl(appName, loginConfig, contentRepository, getSecurityProvider());
     }
 
     /**
@@ -122,8 +126,8 @@ public class AuthenticationConfiguration
     @Nonnull
     @Override
     public TokenProvider getTokenProvider(Root root) {
-        ConfigurationParameters tokenOptions = config.getConfigValue(PARAM_TOKEN_OPTIONS,
new ConfigurationParameters());
-        UserConfiguration uc = securityProvider.getConfiguration(UserConfiguration.class);
+        ConfigurationParameters tokenOptions = getParameters().getConfigValue(PARAM_TOKEN_OPTIONS,
new ConfigurationParameters());
+        UserConfiguration uc = getSecurityProvider().getConfiguration(UserConfiguration.class);
         return new TokenProviderImpl(root, tokenOptions, uc);
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlConfigurationImpl.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authorization/AccessControlConfigurationImpl.java
Thu Jun  6 09:43:40 2013
@@ -35,9 +35,8 @@ import org.apache.jackrabbit.oak.securit
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer;
-import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
 import org.apache.jackrabbit.oak.spi.security.Context;
-import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider;
@@ -47,27 +46,22 @@ import org.apache.jackrabbit.oak.spi.xml
 /**
  * Default implementation of the {@code AccessControlConfiguration}.
  */
-public class AccessControlConfigurationImpl extends SecurityConfiguration.Default implements
AccessControlConfiguration {
-
-    private final SecurityProvider securityProvider;
-    private final ConfigurationParameters config;
+public class AccessControlConfigurationImpl extends ConfigurationBase implements AccessControlConfiguration
{
 
     public AccessControlConfigurationImpl(SecurityProvider securityProvider) {
-        this.securityProvider = securityProvider;
-        config = securityProvider.getParameters(PARAM_ACCESS_CONTROL_OPTIONS);
+        super(securityProvider);
     }
 
     //----------------------------------------------< SecurityConfiguration >---
-
+    @Nonnull
     @Override
-    public Context getContext() {
-        return AccessControlContext.getInstance();
+    public String getName() {
+        return NAME;
     }
 
-    @Nonnull
     @Override
-    public ConfigurationParameters getParameters() {
-        return config;
+    public Context getContext() {
+        return AccessControlContext.getInstance();
     }
 
     @Nonnull
@@ -88,20 +82,20 @@ public class AccessControlConfigurationI
     public List<ValidatorProvider> getValidators(String workspaceName) {
         return ImmutableList.of(
                 new PermissionStoreValidatorProvider(),
-                new PermissionValidatorProvider(securityProvider),
-                new AccessControlValidatorProvider(securityProvider));
+                new PermissionValidatorProvider(getSecurityProvider()),
+                new AccessControlValidatorProvider(getSecurityProvider()));
     }
 
     @Nonnull
     @Override
     public List<ProtectedItemImporter> getProtectedItemImporters() {
-        return Collections.<ProtectedItemImporter>singletonList(new AccessControlImporter(securityProvider));
+        return Collections.<ProtectedItemImporter>singletonList(new AccessControlImporter(getSecurityProvider()));
     }
 
     //-----------------------------------------< AccessControlConfiguration >---
     @Override
     public AccessControlManager getAccessControlManager(Root root, NamePathMapper namePathMapper)
{
-        return new AccessControlManagerImpl(root, namePathMapper, securityProvider);
+        return new AccessControlManagerImpl(root, namePathMapper, getSecurityProvider());
     }
 
     @Nonnull
@@ -113,6 +107,6 @@ public class AccessControlConfigurationI
     @Nonnull
     @Override
     public PermissionProvider getPermissionProvider(Root root, Set<Principal> principals)
{
-        return new PermissionProviderImpl(root, principals, securityProvider);
+        return new PermissionProviderImpl(root, principals, getSecurityProvider());
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImpl.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalConfigurationImpl.java
Thu Jun  6 09:43:40 2013
@@ -21,7 +21,7 @@ import javax.annotation.Nonnull;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
@@ -30,14 +30,13 @@ import org.apache.jackrabbit.oak.spi.sec
 /**
  * Default implementation of the {@code PrincipalConfiguration}
  */
-public class PrincipalConfigurationImpl extends SecurityConfiguration.Default implements
PrincipalConfiguration {
-
-    private final SecurityProvider securityProvider;
+public class PrincipalConfigurationImpl extends ConfigurationBase implements PrincipalConfiguration
{
 
     public PrincipalConfigurationImpl(SecurityProvider securityProvider) {
-        this.securityProvider = securityProvider;
+        super(securityProvider);
     }
 
+    //---------------------------------------------< PrincipalConfiguration >---
     @Nonnull
     @Override
     public PrincipalManager getPrincipalManager(Root root, NamePathMapper namePathMapper)
{
@@ -48,7 +47,14 @@ public class PrincipalConfigurationImpl 
     @Nonnull
     @Override
     public PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper)
{
-        UserConfiguration uc = securityProvider.getConfiguration(UserConfiguration.class);
+        UserConfiguration uc = getSecurityProvider().getConfiguration(UserConfiguration.class);
         return new PrincipalProviderImpl(root, uc, namePathMapper);
     }
+
+    //----------------------------------------------< SecurityConfiguration >---
+    @Nonnull
+    @Override
+    public String getName() {
+        return NAME;
+    }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImpl.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeConfigurationImpl.java
Thu Jun  6 09:43:40 2013
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.securi
 
 import java.util.Collections;
 import java.util.List;
-
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
@@ -27,14 +26,14 @@ import org.apache.jackrabbit.oak.namepat
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
 import org.apache.jackrabbit.oak.spi.security.Context;
-import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration;
 
 /**
  * Configuration for the privilege management component.
  */
-public class PrivilegeConfigurationImpl extends SecurityConfiguration.Default implements
PrivilegeConfiguration {
+public class PrivilegeConfigurationImpl extends ConfigurationBase implements PrivilegeConfiguration
{
 
     //---------------------------------------------< PrivilegeConfiguration >---
     @Nonnull
@@ -52,6 +51,12 @@ public class PrivilegeConfigurationImpl 
     //----------------------------------------------< SecurityConfiguration >---
     @Nonnull
     @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Nonnull
+    @Override
     public List<? extends CommitHook> getCommitHooks(String workspaceName) {
         return Collections.singletonList(new JcrAllCommitHook());
     }

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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -25,9 +25,8 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.spi.commit.ValidatorProvider;
 import org.apache.jackrabbit.oak.spi.lifecycle.WorkspaceInitializer;
-import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationBase;
 import org.apache.jackrabbit.oak.spi.security.Context;
-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;
@@ -38,27 +37,23 @@ import org.apache.jackrabbit.oak.spi.xml
 /**
  * Default implementation of the {@link UserConfiguration}.
  */
-public class UserConfigurationImpl extends SecurityConfiguration.Default implements UserConfiguration
{
-
-    private final ConfigurationParameters config;
-    private final SecurityProvider securityProvider;
+public class UserConfigurationImpl extends ConfigurationBase implements UserConfiguration
{
 
     public UserConfigurationImpl(SecurityProvider securityProvider) {
-        this.config = securityProvider.getParameters(PARAM_USER_OPTIONS);
-        this.securityProvider = securityProvider;
+        super(securityProvider);
     }
 
     //----------------------------------------------< SecurityConfiguration >---
     @Nonnull
     @Override
-    public ConfigurationParameters getParameters() {
-        return config;
+    public String getName() {
+        return NAME;
     }
 
     @Nonnull
     @Override
     public WorkspaceInitializer getWorkspaceInitializer() {
-        return new UserInitializer(securityProvider);
+        return new UserInitializer(getSecurityProvider());
     }
 
     @Nonnull
@@ -70,7 +65,7 @@ public class UserConfigurationImpl exten
     @Nonnull
     @Override
     public List<ProtectedItemImporter> getProtectedItemImporters() {
-        return Collections.<ProtectedItemImporter>singletonList(new UserImporter(config));
+        return Collections.<ProtectedItemImporter>singletonList(new UserImporter(getParameters()));
     }
 
     @Nonnull
@@ -83,14 +78,14 @@ public class UserConfigurationImpl exten
     @Nonnull
     @Override
     public UserManager getUserManager(Root root, NamePathMapper namePathMapper) {
-        return new UserManagerImpl(root, namePathMapper, securityProvider);
+        return new UserManagerImpl(root, namePathMapper, getSecurityProvider());
     }
 
     @Nonnull
     @Override
     public AuthorizableActionProvider getAuthorizableActionProvider() {
         // TODO OAK-521: add proper implementation
-        AuthorizableActionProvider defProvider = new DefaultAuthorizableActionProvider(securityProvider,
config);
-        return config.getConfigValue(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER, defProvider);
+        AuthorizableActionProvider defProvider = new DefaultAuthorizableActionProvider(getSecurityProvider(),
getParameters());
+        return getParameters().getConfigValue(UserConstants.PARAM_AUTHORIZABLE_ACTION_PROVIDER,
defProvider);
     }
 }

Added: 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=1490214&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ConfigurationBase.java
Thu Jun  6 09:43:40 2013
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.security;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Abstract base implementation for the various security configurations.
+ */
+public abstract class ConfigurationBase extends SecurityConfiguration.Default {
+
+    private final SecurityProvider securityProvider;
+    private final ConfigurationParameters config;
+
+    public ConfigurationBase() {
+        securityProvider = null;
+        config = ConfigurationParameters.EMPTY;
+    }
+
+    public ConfigurationBase(SecurityProvider securityProvider) {
+        this.securityProvider = securityProvider;
+        this.config = securityProvider.getParameters(getName());
+    }
+
+    @Nonnull
+    protected SecurityProvider getSecurityProvider() {
+        if (securityProvider == null) {
+            throw new IllegalStateException();
+        }
+        return securityProvider;
+    }
+
+    //----------------------------------------------< SecurityConfiguration >---
+    @Nonnull
+    @Override
+    public ConfigurationParameters getParameters() {
+        return config;
+    }
+}

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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -17,7 +17,11 @@
 package org.apache.jackrabbit.oak.spi.security;
 
 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 javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -44,6 +48,31 @@ public class ConfigurationParameters {
         this.options = (options == null) ? Collections.<String, Object>emptyMap() :
Collections.unmodifiableMap(options);
     }
 
+    public static ConfigurationParameters newInstance(Properties properties) {
+        if (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));
+        }
+        return new ConfigurationParameters(options);
+    }
+
+    public static ConfigurationParameters newInstance(Dictionary<String, Object> properties)
{
+        if (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();
+            options.put(key, properties.get(key));
+        }
+        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.

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -33,6 +33,9 @@ import org.apache.jackrabbit.oak.spi.xml
 public interface SecurityConfiguration {
 
     @Nonnull
+    String getName();
+
+    @Nonnull
     ConfigurationParameters getParameters();
 
     @Nonnull
@@ -57,6 +60,12 @@ public interface SecurityConfiguration {
 
         @Nonnull
         @Override
+        public String getName() {
+            return "org.apache.jackrabbit.oak";
+        }
+
+        @Nonnull
+        @Override
         public ConfigurationParameters getParameters() {
             return ConfigurationParameters.EMPTY;
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthenticationConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthenticationConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthenticationConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authentication/AuthenticationConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -28,10 +28,10 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface AuthenticationConfiguration extends SecurityConfiguration {
 
-    String PARAM_AUTHENTICATION_OPTIONS = "org.apache.jackrabbit.oak.authentication.options";
-    String PARAM_TOKEN_OPTIONS = "org.apache.jackrabbit.oak.authentication.token.options";
+    String NAME = "org.apache.jackrabbit.oak.authentication";
 
-    String PARAM_APP_NAME = "org.apache.jackrabbit.oak.auth.appName";
+    String PARAM_TOKEN_OPTIONS = "org.apache.jackrabbit.oak.authentication.token";
+    String PARAM_APP_NAME = "org.apache.jackrabbit.oak.authentication.appName";
     String DEFAULT_APP_NAME = "jackrabbit.oak";
 
     @Nonnull
@@ -39,4 +39,4 @@ public interface AuthenticationConfigura
 
     @Nonnull
     TokenProvider getTokenProvider(Root root);
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/AccessControlConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -32,7 +32,7 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface AccessControlConfiguration extends SecurityConfiguration {
 
-    String PARAM_ACCESS_CONTROL_OPTIONS = "org.apache.jackrabbit.oak.accesscontrol.options";
+    String NAME = "org.apache.jackrabbit.oak.accesscontrol";
 
     @Nonnull
     AccessControlManager getAccessControlManager(@Nonnull Root root,

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -28,6 +28,8 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface PrincipalConfiguration extends SecurityConfiguration {
 
+    String NAME = "org.apache.jackrabbit.oak.principal";
+
     /**
      * Returns an instance of {@link PrincipalManager} that can be used
      * to query and retrieve principals such as needed for JCR access control
@@ -68,4 +70,4 @@ public interface PrincipalConfiguration 
      */
     @Nonnull
     PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper);
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -29,6 +29,8 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface PrivilegeConfiguration extends SecurityConfiguration {
 
+    String NAME = "org.apache.jackrabbit.oak.privilege";
+
     /**
      * Creates a new instance of {@link PrivilegeManager}.
      *

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfiguration.java?rev=1490214&r1=1490213&r2=1490214&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConfiguration.java
Thu Jun  6 09:43:40 2013
@@ -29,11 +29,11 @@ import org.apache.jackrabbit.oak.spi.sec
  */
 public interface UserConfiguration extends SecurityConfiguration {
 
-    String PARAM_USER_OPTIONS = "org.apache.jackrabbit.oak.user.options";
+    String NAME = "org.apache.jackrabbit.oak.user";
 
     @Nonnull
     UserManager getUserManager(Root root, NamePathMapper namePathMapper);
 
     @Nonnull
     AuthorizableActionProvider getAuthorizableActionProvider();
-}
\ No newline at end of file
+}

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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -85,7 +85,7 @@ public class Jr2CompatibilityTest extend
         Map<String, String> map = Collections.singletonMap(AccessControlConstants.PARAM_PERMISSIONS_JR2,
AccessControlConstants.VALUE_PERMISSIONS_JR2);
         ConfigurationParameters acConfig = new ConfigurationParameters(map);
 
-        return new ConfigurationParameters(ImmutableMap.of(AccessControlConfiguration.PARAM_ACCESS_CONTROL_OPTIONS,
acConfig));
+        return new ConfigurationParameters(ImmutableMap.of(AccessControlConfiguration.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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -88,7 +88,7 @@ public class PermissionProviderImplTest 
         map.put(PARAM_ADMINISTRATOR_PRINCIPALS, new String[] {ADMINISTRATOR_GROUP});
         ConfigurationParameters acConfig = new ConfigurationParameters(map);
 
-        return new ConfigurationParameters(ImmutableMap.of(AccessControlConfiguration.PARAM_ACCESS_CONTROL_OPTIONS,
acConfig));
+        return new ConfigurationParameters(ImmutableMap.of(AccessControlConfiguration.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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -142,7 +142,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.PARAM_USER_OPTIONS,
new ConfigurationParameters(userParams)));
+        ConfigurationParameters params = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME,
new ConfigurationParameters(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/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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -50,7 +50,7 @@ public class AccessControlActionTest ext
         map.put(AccessControlAction.USER_PRIVILEGE_NAMES, PrivilegeConstants.JCR_ALL);
 
         ConfigurationParameters userConfig = new ConfigurationParameters(map);
-        return new ConfigurationParameters(ImmutableMap.of(UserConfiguration.PARAM_USER_OPTIONS,
userConfig));
+        return new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME, userConfig));
     }
 
     @Test

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=1490214&r1=1490213&r2=1490214&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
Thu Jun  6 09:43:40 2013
@@ -71,7 +71,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.PARAM_USER_OPTIONS,
new ConfigurationParameters(userParams)));
+            ConfigurationParameters config = new ConfigurationParameters(ImmutableMap.of(UserConfiguration.NAME,
new ConfigurationParameters(userParams)));
 
             SecurityProvider securityProvider = new SecurityProviderImpl(config);
             String dir = "target/mk-tck-" + System.currentTimeMillis();



Mime
View raw message