jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r934418 - in /jackrabbit/branches/2.1: ./ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Date Thu, 15 Apr 2010 14:08:14 GMT
Author: angela
Date: Thu Apr 15 14:08:14 2010
New Revision: 934418

URL: http://svn.apache.org/viewvc?rev=934418&view=rev
Log:
JCR-2607: AbstractWebdavServlet: add protected method sendUnauthorized   [merge changes into
2.1 branch]

Modified:
    jackrabbit/branches/2.1/   (props changed)
    jackrabbit/branches/2.1/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java

Propchange: jackrabbit/branches/2.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr 15 14:08:14 2010
@@ -2,4 +2,4 @@
 /jackrabbit/sandbox/JCR-1456:774917-886178
 /jackrabbit/sandbox/JCR-2170:812417-816332
 /jackrabbit/sandbox/tripod-JCR-2209:795441-795863
-/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694
+/jackrabbit/trunk:931121,931479,931483-931484,931504,931609,931613,931838,931919,932318-932319,933144,933197,933203,933213,933216,933554,933646,933694,934412

Modified: jackrabbit/branches/2.1/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.1/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java?rev=934418&r1=934417&r2=934418&view=diff
==============================================================================
--- jackrabbit/branches/2.1/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/branches/2.1/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Thu Apr 15 14:08:14 2010
@@ -201,8 +201,7 @@ abstract public class AbstractWebdavServ
 
         } catch (DavException e) {
             if (e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) {
-                webdavResponse.setHeader("WWW-Authenticate", getAuthenticateHeaderValue());
-                webdavResponse.sendError(e.getErrorCode(), e.getStatusPhrase());
+                sendUnauthorized(webdavRequest, webdavResponse, e);
             } else {
                 webdavResponse.sendError(e);
             }
@@ -212,6 +211,25 @@ abstract public class AbstractWebdavServ
     }
 
     /**
+     * Sets the "WWW-Authenticate" header and writes the appropriate error
+     * to the given webdav response.
+     *
+     * @param request The webdav request.
+     * @param response The webdav response.
+     * @param error The DavException that leads to the unauthorized response.
+     * @throws IOException
+     */
+    protected void sendUnauthorized(WebdavRequest request,
+                                    WebdavResponse response, DavException error) throws IOException
{
+        response.setHeader("WWW-Authenticate", getAuthenticateHeaderValue());
+        if (error == null || error.getErrorCode() != HttpServletResponse.SC_UNAUTHORIZED)
{
+            response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
+        } else {
+            response.sendError(error.getErrorCode(), error.getStatusPhrase());
+        }
+    }
+
+    /**
      * Executes the respective method in the given webdav context
      *
      * @param request



Mime
View raw message