shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ssiev...@apache.org
Subject svn commit: r1354114 - /shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
Date Tue, 26 Jun 2012 17:16:57 GMT
Author: ssievers
Date: Tue Jun 26 17:16:56 2012
New Revision: 1354114

URL: http://svn.apache.org/viewvc?rev=1354114&view=rev
Log:
SHINDIG-1800 | Enhance AuthenticationServletFilter to be more easily overrideable

Modified:
    shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java

Modified: shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java?rev=1354114&r1=1354113&r2=1354114&view=diff
==============================================================================
--- shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
(original)
+++ shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/AuthenticationServletFilter.java
Tue Jun 26 17:16:56 2012
@@ -116,15 +116,11 @@ public class AuthenticationServletFilter
         }
       }
       if (iae.getRedirect() != null) {
-        resp.sendRedirect(iae.getRedirect());
+        onRedirect(req, resp, iae);
       } else {
         // Set auth header
         setAuthHeader(authHeader, resp);
-
-        // For now append the cause message if set, this allows us to send any underlying
oauth errors
-        String message = (cause==null) ? iae.getMessage() : iae.getMessage() + cause.getMessage();
-
-        resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, message);
+        onError(req, resp, iae);
       }
     }
   }
@@ -137,6 +133,44 @@ public class AuthenticationServletFilter
     return realm;
   }
 
+  /**
+   * Override this to perform extra error processing. Headers will have already been set
on the
+   * response.
+   *
+   * @param req
+   *          the current http request for this filter
+   * @param resp
+   *          the current http response for this filter
+   * @param iae
+   *          the exception that caused the error path
+   * @throws IOException
+   */
+  protected void onError(HttpServletRequest req, HttpServletResponse resp,
+          AuthenticationHandler.InvalidAuthenticationException iae) throws IOException {
+    Throwable cause = iae.getCause();
+
+    // For now append the cause message if set, this allows us to send any underlying oauth
errors
+    String message = (cause == null) ? iae.getMessage() : iae.getMessage() + cause.getMessage();
+    resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, message);
+  }
+
+  /**
+   * Override this to perform extra processing on redirect. Headers will have already been
set on
+   * the response.
+   *
+   * @param req
+   *          the current http request for this filter
+   * @param resp
+   *          the current http response for this filter
+   * @param iae
+   *          the exception that caused the redirect path
+   * @throws IOException
+   */
+  protected void onRedirect(HttpServletRequest req, HttpServletResponse resp,
+          AuthenticationHandler.InvalidAuthenticationException iae) throws IOException {
+    resp.sendRedirect(iae.getRedirect());
+  }
+
   private void setAuthHeader(@Nullable String authHeader, HttpServletResponse response) {
     if (authHeader != null) {
       response.addHeader(WWW_AUTHENTICATE_HEADER, authHeader);



Mime
View raw message