jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1399570 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/ oak-core/src/test/java/org/apache/jackrabbit/oak/ oak-core/src/test/java/org/apac...
Date Thu, 18 Oct 2012 09:54:01 GMT
Author: angela
Date: Thu Oct 18 09:54:00 2012
New Revision: 1399570

URL: http://svn.apache.org/viewvc?rev=1399570&view=rev
Log:
 OAK-91 - Implement Authentication Support (WIP)
 
workaround missing repository configuration in test-setup (TCK, AbstractRepositoryTest, AbstractOakTest)

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/OakConfiguration.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/spi/security/ConfigurationParameters.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/DefaultLoginModuleTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/OakConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/OakConfiguration.java?rev=1399570&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/OakConfiguration.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/OakConfiguration.java
Thu Oct 18 09:54:00 2012
@@ -0,0 +1,57 @@
+/*
+ * 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.security;
+
+import java.util.Collections;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+
+import org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl;
+import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * OakConfiguration... tmp solution missing repo-configuration in test-setup.
+ * TODO: remove again once OAK-17 is addressed.
+ */
+public class OakConfiguration extends Configuration {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(OakConfiguration.class);
+
+    ConfigurationParameters loginConfiguration;
+
+    public OakConfiguration() {
+        this(ConfigurationParameters.EMPTY);
+    }
+
+    public OakConfiguration(ConfigurationParameters loginConfiguration) {
+        this.loginConfiguration = loginConfiguration;
+    }
+
+    @Override
+    public AppConfigurationEntry[] getAppConfigurationEntry(String applicationName) {
+        AppConfigurationEntry entry = new AppConfigurationEntry(
+                LoginModuleImpl.class.getName(),
+                AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+                loginConfiguration.getConfigValue(applicationName, Collections.<String,
Object>emptyMap()));
+        return new AppConfigurationEntry[] {entry};
+    }
+}
\ No newline at end of file

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=1399570&r1=1399569&r2=1399570&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 Oct 18 09:54:00 2012
@@ -16,17 +16,14 @@
  */
 package org.apache.jackrabbit.oak.security;
 
-import java.util.Collections;
 import javax.annotation.Nonnull;
 import javax.jcr.Session;
-import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.Configuration;
 
 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.security.authentication.LoginContextProviderImpl;
-import org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl;
 import org.apache.jackrabbit.oak.security.authentication.token.TokenProviderImpl;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlProviderImpl;
 import org.apache.jackrabbit.oak.security.principal.PrincipalManagerImpl;
@@ -77,7 +74,7 @@ public class SecurityProviderImpl implem
             loginConfig = Configuration.getConfiguration();
         } catch (SecurityException e) {
             log.warn("Failed to retrieve login configuration: using default.", e);
-            loginConfig = new OakConfiguration();
+            loginConfig = new OakConfiguration(configuration); // TODO: define configuration
structure
             Configuration.setConfiguration(loginConfig);
         }
         return new LoginContextProviderImpl(appName, loginConfig, nodeStore, this);
@@ -130,17 +127,4 @@ public class SecurityProviderImpl implem
             }
         };
     }
-
-    //--------------------------------------------------------------------------
-    private class OakConfiguration extends Configuration {
-
-        @Override
-        public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
-            AppConfigurationEntry entry = new AppConfigurationEntry(
-                    LoginModuleImpl.class.getName(),
-                    AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
-                    Collections.<String, Object>emptyMap());
-            return new AppConfigurationEntry[] {entry};
-        }
-    }
 }

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=1399570&r1=1399569&r2=1399570&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 Oct 18 09:54:00 2012
@@ -32,6 +32,8 @@ public class ConfigurationParameters {
      */
     private static final Logger log = LoggerFactory.getLogger(ConfigurationParameters.class);
 
+    public static final ConfigurationParameters EMPTY = new ConfigurationParameters();
+
     private final Map<String, Object> options;
 
     public ConfigurationParameters() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java?rev=1399570&r1=1399569&r2=1399570&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/AbstractOakTest.java
Thu Oct 18 09:54:00 2012
@@ -22,6 +22,7 @@ import java.util.List;
 import javax.jcr.Credentials;
 import javax.jcr.NoSuchWorkspaceException;
 import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.Configuration;
 import javax.security.auth.login.LoginException;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
@@ -30,6 +31,7 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.nodetype.InitialContent;
+import org.apache.jackrabbit.oak.security.OakConfiguration;
 import org.apache.jackrabbit.oak.spi.lifecycle.CompositeMicroKernelTracker;
 import org.apache.jackrabbit.oak.spi.lifecycle.MicroKernelTracker;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
@@ -49,6 +51,8 @@ public abstract class AbstractOakTest {
     @Before
     public void before() throws Exception {
         contentRepository = createRepository();
+        // TODO: OAK-17. workaround for missing test configuration
+        Configuration.setConfiguration(new OakConfiguration());
     }
 
     protected MicroKernel createMicroKernelWithInitialContent() {

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/DefaultLoginModuleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/DefaultLoginModuleTest.java?rev=1399570&r1=1399569&r2=1399570&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/DefaultLoginModuleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authentication/DefaultLoginModuleTest.java
Thu Oct 18 09:54:00 2012
@@ -64,7 +64,9 @@ public class DefaultLoginModuleTest exte
     @After
     public void after() throws Exception {
         Configuration.setConfiguration(null);
-        admin.close();
+        if (admin != null) {
+            admin.close();
+        }
     }
 
     @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java?rev=1399570&r1=1399569&r2=1399570&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/AbstractRepositoryTest.java
Thu Oct 18 09:54:00 2012
@@ -18,18 +18,20 @@ package org.apache.jackrabbit.oak.jcr;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-
 import javax.jcr.GuestCredentials;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
+import javax.security.auth.login.Configuration;
 
 import org.apache.jackrabbit.mk.api.MicroKernel;
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.security.OakConfiguration;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
 import org.junit.After;
+import org.junit.Before;
 
 /**
  * Abstract base class for repository tests providing methods for accessing
@@ -45,6 +47,12 @@ public abstract class AbstractRepository
     private Repository repository = null;
     private Session adminSession = null;
 
+    @Before
+    public void before() throws Exception {
+        // TODO: OAK-17. workaround for missing test configuration
+        Configuration.setConfiguration(new OakConfiguration());
+    }
+
     @After
     public void logout() throws RepositoryException {
         // release session field

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java?rev=1399570&r1=1399569&r2=1399570&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/OakRepositoryStub.java
Thu Oct 18 09:54:00 2012
@@ -19,15 +19,16 @@ package org.apache.jackrabbit.oak.jcr;
 import java.security.Principal;
 import java.util.Properties;
 import java.util.concurrent.Executors;
-
 import javax.jcr.Credentials;
 import javax.jcr.GuestCredentials;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.security.auth.login.Configuration;
 
 import org.apache.jackrabbit.mk.core.MicroKernelImpl;
+import org.apache.jackrabbit.oak.security.OakConfiguration;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.test.NotExecutableException;
 import org.apache.jackrabbit.test.RepositoryStub;
@@ -45,6 +46,9 @@ public class OakRepositoryStub extends R
     public OakRepositoryStub(Properties settings) throws RepositoryException {
         super(settings);
 
+        // TODO: OAK-17. workaround for missing test configuration
+        Configuration.setConfiguration(new OakConfiguration());
+
         String dir = "target/mk-tck-" + System.currentTimeMillis();
         repository = new RepositoryImpl(
                 new MicroKernelImpl(dir),



Mime
View raw message