jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1446171 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/ main/java/org/apache/jackrabbit/oak/security/authentication/ main/java/org/apache/jackrabbit/oak/security/principal/ main/java/org/apache/jackra...
Date Thu, 14 Feb 2013 13:33:00 GMT
Author: angela
Date: Thu Feb 14 13:32:59 2013
New Revision: 1446171

URL: http://svn.apache.org/r1446171
Log:
OAK-17: simplify security related tmp. configurations

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/principal/PrincipalConfigurationImpl.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/OpenSecurityProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityProvider.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.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=1446171&r1=1446170&r2=1446171&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 Feb 14 13:32:59 2013
@@ -36,10 +36,6 @@ import org.apache.jackrabbit.oak.spi.sec
 
 public class SecurityProviderImpl implements SecurityProvider {
 
-    public static final String PARAM_AUTHENTICATION_OPTIONS = "org.apache.jackrabbit.oak.authentication.options";
-    public static final String PARAM_PRINCIPAL_OPTIONS = "org.apache.jackrabbit.oak.principal.options";
-    public static final String PARAM_USER_OPTIONS = "org.apache.jackrabbit.oak.user.options";
-
     private final ConfigurationParameters configuration;
 
     public SecurityProviderImpl() {
@@ -52,6 +48,12 @@ public class SecurityProviderImpl implem
 
     @Nonnull
     @Override
+    public ConfigurationParameters getConfiguration(String name) {
+        return (name == null) ? configuration : configuration.getConfigValue(name, new ConfigurationParameters());
+    }
+
+    @Nonnull
+    @Override
     public Iterable<SecurityConfiguration> getSecurityConfigurations() {
         Set<SecurityConfiguration> scs = new HashSet<SecurityConfiguration>();
         scs.add(getAccessControlConfiguration());
@@ -64,7 +66,7 @@ public class SecurityProviderImpl implem
     @Nonnull
     @Override
     public AuthenticationConfiguration getAuthenticationConfiguration() {
-        return new AuthenticationConfigurationImpl(this, getOptions(PARAM_AUTHENTICATION_OPTIONS));
+        return new AuthenticationConfigurationImpl(this);
     }
 
     @Nonnull
@@ -82,22 +84,12 @@ public class SecurityProviderImpl implem
     @Nonnull
     @Override
     public UserConfiguration getUserConfiguration() {
-        return new UserConfigurationImpl(this, getOptions(PARAM_USER_OPTIONS));
+        return new UserConfigurationImpl(this);
     }
 
     @Nonnull
     @Override
     public PrincipalConfiguration getPrincipalConfiguration() {
-        return new PrincipalConfigurationImpl(this, getOptions(PARAM_PRINCIPAL_OPTIONS));
-    }
-
-    //------------------------------------------------------------< private >---
-
-    /**
-     * @param name
-     * @return
-     */
-    private ConfigurationParameters getOptions(String name) {
-        return configuration.getConfigValue(name, new ConfigurationParameters());
+        return new PrincipalConfigurationImpl(this);
     }
 }

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=1446171&r1=1446170&r2=1446171&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 Feb 14 13:32:59 2013
@@ -39,23 +39,24 @@ public class AuthenticationConfiguration
 
     private static final Logger log = LoggerFactory.getLogger(AuthenticationConfigurationImpl.class);
 
+    public static final String PARAM_AUTHENTICATION_OPTIONS = "org.apache.jackrabbit.oak.authentication.options";
     public static final String PARAM_APP_NAME = "org.apache.jackrabbit.oak.auth.appName";
     private static final String DEFAULT_APP_NAME = "jackrabbit.oak";
 
     public static final String PARAM_TOKEN_OPTIONS = "org.apache.jackrabbit.oak.token.options";
 
     private final SecurityProvider securityProvider;
-    private final ConfigurationParameters options;
+    private final ConfigurationParameters config;
 
-    public AuthenticationConfigurationImpl(SecurityProvider securityProvider, ConfigurationParameters
options) {
+    public AuthenticationConfigurationImpl(SecurityProvider securityProvider) {
         this.securityProvider = securityProvider;
-        this.options = options;
+        this.config = securityProvider.getConfiguration(PARAM_AUTHENTICATION_OPTIONS);
     }
 
     @Nonnull
     @Override
     public LoginContextProvider getLoginContextProvider(NodeStore nodeStore, QueryIndexProvider
indexProvider) {
-        String appName = options.getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
+        String appName = config.getConfigValue(PARAM_APP_NAME, DEFAULT_APP_NAME);
         Configuration loginConfig = null;
         try {
             loginConfig = Configuration.getConfiguration();
@@ -70,7 +71,7 @@ public class AuthenticationConfiguration
         if (loginConfig == null) {
             // TODO: define configuration structure
             // TODO: review if having a default is desirable or if login should fail without
valid login configuration.
-            loginConfig = ConfigurationUtil.getDefaultConfiguration(options);
+            loginConfig = ConfigurationUtil.getDefaultConfiguration(config);
         }
         return new LoginContextProviderImpl(appName, loginConfig, nodeStore, indexProvider,
securityProvider);
     }
@@ -78,7 +79,7 @@ public class AuthenticationConfiguration
     @Nonnull
     @Override
     public TokenProvider getTokenProvider(Root root) {
-        ConfigurationParameters tokenOptions = options.getConfigValue(PARAM_TOKEN_OPTIONS,
new ConfigurationParameters());
+        ConfigurationParameters tokenOptions = config.getConfigValue(PARAM_TOKEN_OPTIONS,
new ConfigurationParameters());
         return new TokenProviderImpl(root, tokenOptions, securityProvider.getUserConfiguration());
     }
 }
\ No newline at end of file

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=1446171&r1=1446170&r2=1446171&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 Feb 14 13:32:59 2013
@@ -21,7 +21,6 @@ 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.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration;
@@ -34,7 +33,7 @@ public class PrincipalConfigurationImpl 
 
     private final SecurityProvider securityProvider;
 
-    public PrincipalConfigurationImpl(SecurityProvider securityProvider, ConfigurationParameters
options) {
+    public PrincipalConfigurationImpl(SecurityProvider securityProvider) {
         this.securityProvider = securityProvider;
     }
 
@@ -50,4 +49,4 @@ public class PrincipalConfigurationImpl 
     public PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper)
{
         return new PrincipalProviderImpl(root, securityProvider.getUserConfiguration(), namePathMapper);
     }
-}
\ No newline at end of file
+}

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=1446171&r1=1446170&r2=1446171&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 Feb 14 13:32:59 2013
@@ -40,11 +40,13 @@ import org.apache.jackrabbit.oak.spi.xml
  */
 public class UserConfigurationImpl extends SecurityConfiguration.Default implements UserConfiguration
{
 
+    public static final String PARAM_USER_OPTIONS = "org.apache.jackrabbit.oak.user.options";
+
     private final ConfigurationParameters config;
     private final SecurityProvider securityProvider;
 
-    public UserConfigurationImpl(SecurityProvider securityProvider, ConfigurationParameters
config) {
-        this.config = config;
+    public UserConfigurationImpl(SecurityProvider securityProvider) {
+        this.config = securityProvider.getConfiguration(PARAM_USER_OPTIONS);
         this.securityProvider = securityProvider;
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java?rev=1446171&r1=1446170&r2=1446171&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/OpenSecurityProvider.java
Thu Feb 14 13:32:59 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.spi.se
 
 import java.util.Collections;
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authentication.OpenAuthenticationConfiguration;
@@ -34,6 +35,12 @@ public class OpenSecurityProvider implem
 
     @Nonnull
     @Override
+    public ConfigurationParameters getConfiguration(@Nullable String name) {
+        return ConfigurationParameters.EMPTY;
+    }
+
+    @Nonnull
+    @Override
     public Iterable<SecurityConfiguration> getSecurityConfigurations() {
         return Collections.<SecurityConfiguration>singletonList(getAccessControlConfiguration());
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityProvider.java?rev=1446171&r1=1446170&r2=1446171&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/SecurityProvider.java
Thu Feb 14 13:32:59 2013
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.oak.spi.security;
 
 import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 
 import org.apache.jackrabbit.oak.spi.security.authentication.AuthenticationConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
@@ -30,6 +31,9 @@ import org.apache.jackrabbit.oak.spi.sec
 public interface SecurityProvider {
 
     @Nonnull
+    ConfigurationParameters getConfiguration(@Nullable String name);
+
+    @Nonnull
     Iterable<SecurityConfiguration> getSecurityConfigurations();
 
     @Nonnull
@@ -46,4 +50,4 @@ public interface SecurityProvider {
 
     @Nonnull
     PrincipalConfiguration getPrincipalConfiguration();
-}
\ No newline at end of file
+}

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=1446171&r1=1446170&r2=1446171&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
Thu Feb 14 13:32:59 2013
@@ -184,13 +184,13 @@ public class PasswordValidationActionTes
         private final AuthorizableAction[] actions;
 
         private TestSecurityProvider() {
-            this.actions = new AuthorizableAction[] {pwAction, testAction};
+            this.actions = new AuthorizableAction[]{pwAction, testAction};
         }
 
         @Nonnull
         @Override
         public UserConfiguration getUserConfiguration() {
-            return new UserConfigurationImpl(this, ConfigurationParameters.EMPTY) {
+            return new UserConfigurationImpl(this) {
 
                 @Nonnull
                 @Override



Mime
View raw message