jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r934412 - /jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Date Thu, 15 Apr 2010 13:58:12 GMT
Author: angela
Date: Thu Apr 15 13:58:12 2010
New Revision: 934412

URL: http://svn.apache.org/viewvc?rev=934412&view=rev
Log:
JCR-2607: AbstractWebdavServlet: add protected method sendUnauthorized

Modified:
    jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java

Modified: jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java?rev=934412&r1=934411&r2=934412&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/server/AbstractWebdavServlet.java
Thu Apr 15 13:58:12 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