incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1157048 - /sling/trunk/bundles/jcr/davex/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java
Date Fri, 12 Aug 2011 11:05:02 GMT
Author: cziegeler
Date: Fri Aug 12 11:05:02 2011
New Revision: 1157048

URL: http://svn.apache.org/viewvc?rev=1157048&view=rev
Log:
SLING-2167 : Use session from default implementation to let the tests pass

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=1157048&r1=1157047&r2=1157048&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
Fri Aug 12 11:05:02 2011
@@ -21,10 +21,12 @@ import java.util.Enumeration;
 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.ServletException;
 import javax.servlet.http.HttpServletRequest;
 
@@ -101,10 +103,10 @@ public class SlingDavExServlet extends J
         return repository;
     }
 
+    private static char[] EMPTY_PW = new char[0];
+
     @Override
     protected SessionProvider getSessionProvider() {
-        // TODO - we have to fix this!!
-        final SessionProvider sp = super.getSessionProvider();
         return new SessionProvider() {
 
             public Session getSession(final HttpServletRequest req,
@@ -113,15 +115,20 @@ public class SlingDavExServlet extends J
             throws LoginException, ServletException, RepositoryException {
                 final ResourceResolver resolver = (ResourceResolver) req.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER);
                 if ( resolver != null ) {
-                    final Session superSession = sp.getSession(req, repository, workspace);
-                    return superSession;
+                    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!
+                    if ( session != null ) {
+                        final Credentials credentials = new SimpleCredentials(session.getUserID(),
EMPTY_PW);
+                        final Session newSession = session.impersonate(credentials);
+                        return newSession;
+                    }
                 }
                 return null;
             }
 
-            public void releaseSession(Session paramSession) {
-                // nothing to do
-
+            public void releaseSession(final Session session) {
+                session.logout();
             }
         };
     }



Mime
View raw message