incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1221546 - /sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
Date Wed, 21 Dec 2011 01:03:15 GMT
Author: justin
Date: Wed Dec 21 01:03:15 2011
New Revision: 1221546

URL: http://svn.apache.org/viewvc?rev=1221546&view=rev
Log:
SLING-2325 - using request attribute flag rather than impersonation to ensure that a session
lives past the current request

Modified:
    sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java

Modified: sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java?rev=1221546&r1=1221545&r2=1221546&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
(original)
+++ sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
Wed Dec 21 01:03:15 2011
@@ -20,12 +20,10 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Map;
 
-import javax.jcr.Credentials;
 import javax.jcr.LoginException;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.SimpleCredentials;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.felix.scr.annotations.Activate;
@@ -76,6 +74,15 @@ public class SlingDavExServlet extends J
      */
     private static final String PAR_AUTH_REQ = "sling.auth.requirements";
 
+    /**
+     * Constant copied from <code>SlingConstants</code> to enable compatibility
+     * with older API bundle.
+     *
+     * TODO - remove once Sling API 2.3.0 has been released
+     */
+    private static final String ATTR_RESOURCE_RESOLVER_SKIP_CLOSE = "org.apache.sling.api.resource.ResourceResolver.skip.close";
+
+
     @Reference
     private Repository repository;
 
@@ -158,8 +165,6 @@ public class SlingDavExServlet extends J
         return repository;
     }
 
-    private static char[] EMPTY_PW = new char[0];
-
     @Override
     protected SessionProvider getSessionProvider() {
         return new SessionProvider() {
@@ -172,11 +177,11 @@ public class SlingDavExServlet extends J
                 if ( resolver != null ) {
                     final Session session = resolver.adaptTo(Session.class);
                     // as the session might be longer used by davex than the request
-                    // we have to create a new session!
+                    // we have to tell the engine and authenticators to leave the resource
+                    // resolver open
                     if ( session != null ) {
-                        final Credentials credentials = new SimpleCredentials(session.getUserID(),
EMPTY_PW);
-                        final Session newSession = session.impersonate(credentials);
-                        return newSession;
+                        req.setAttribute(ATTR_RESOURCE_RESOLVER_SKIP_CLOSE, "");
+                        return session;
                     }
                 }
                 return null;



Mime
View raw message