jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1380738 - in /jackrabbit/oak/trunk: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/ oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/
Date Tue, 04 Sep 2012 16:48:27 GMT
Author: jukka
Date: Tue Sep  4 16:48:27 2012
New Revision: 1380738

URL: http://svn.apache.org/viewvc?rev=1380738&view=rev
Log:
OAK-256: JAAS Authentication failing in OSGi env due to classloading issue

Force the thread context class loader to come from oak-core when doing a Repository.login()
call.

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
      - copied, changed from r1380251, jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
    jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java?rev=1380738&r1=1380737&r2=1380738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/Activator.java
Tue Sep  4 16:48:27 2012
@@ -25,7 +25,6 @@ import java.util.concurrent.ScheduledExe
 import javax.jcr.Repository;
 
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -70,7 +69,7 @@ public class Activator implements Bundle
             ContentRepository repository = (ContentRepository) service;
             services.put(reference, context.registerService(
                     Repository.class.getName(),
-                    new RepositoryImpl(repository, executor),
+                    new OsgiRepository(repository, executor),
                     new Properties()));
             return service;
         } else {

Copied: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
(from r1380251, jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java?p2=jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java&p1=jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java&r1=1380251&r2=1380738&rev=1380738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/osgi/OsgiRepository.java
Tue Sep  4 16:48:27 2012
@@ -6,7 +6,7 @@
  * (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
+ *      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,
@@ -14,34 +14,42 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.oak.sling;
+package org.apache.jackrabbit.oak.jcr.osgi;
 
 import java.util.concurrent.ScheduledExecutorService;
 
+import javax.jcr.Credentials;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.core.ContentRepositoryImpl;
 import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
-import org.apache.sling.jcr.api.SlingRepository;
 
-public class SlingRepositoryImpl
-        extends RepositoryImpl implements SlingRepository {
+/**
+ * Workaround to a JAAS class loading issue in OSGi environments.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/OAK-256">OAK-256</a>
+ */
+public class OsgiRepository extends RepositoryImpl {
 
-    public SlingRepositoryImpl(
+    public OsgiRepository(
             ContentRepository repository, ScheduledExecutorService executor) {
         super(repository, executor);
     }
 
     @Override
-    public String getDefaultWorkspace() {
-        return "default";
-    }
-
-    @Override
-    public Session loginAdministrative(String workspace)
+    public Session login(Credentials credentials, String workspace)
             throws RepositoryException {
-        return login(workspace);
+        Thread thread = Thread.currentThread();
+        ClassLoader loader = thread.getContextClassLoader();
+        try {
+            thread.setContextClassLoader(
+                    ContentRepositoryImpl.class.getClassLoader());
+            return super.login(credentials, workspace);
+        } finally {
+            thread.setContextClassLoader(loader);
+        }
     }
 
 }

Modified: jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java?rev=1380738&r1=1380737&r2=1380738&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-sling/src/main/java/org/apache/jackrabbit/oak/sling/SlingRepositoryImpl.java
Tue Sep  4 16:48:27 2012
@@ -22,11 +22,11 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.jackrabbit.oak.api.ContentRepository;
-import org.apache.jackrabbit.oak.jcr.RepositoryImpl;
+import org.apache.jackrabbit.oak.jcr.osgi.OsgiRepository;
 import org.apache.sling.jcr.api.SlingRepository;
 
 public class SlingRepositoryImpl
-        extends RepositoryImpl implements SlingRepository {
+        extends OsgiRepository implements SlingRepository {
 
     public SlingRepositoryImpl(
             ContentRepository repository, ScheduledExecutorService executor) {



Mime
View raw message