This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.davex-1.1.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-davex.git
commit 76c54d4c5d55d3cb9efcd3d17a9b67d4a2c91991 Author: Carsten Ziegeler <[email protected]> AuthorDate: Fri Aug 12 11:05:02 2011 +0000 SLING-2167 : Use session from default implementation to let the tests pass git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/davex@1157048 13f79535-47bb-0310-9956-ffa450edef68 --- .../jcr/davex/impl/servlets/SlingDavExServlet.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java index b3f9ecb..e3e6ba7 100644 --- a/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java +++ b/src/main/java/org/apache/sling/jcr/davex/impl/servlets/SlingDavExServlet.java @@ -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 JcrRemotingServlet { 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 JcrRemotingServlet { 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(); } }; } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
