Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51277
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 31 May 2011 13:06:11 +0000 (13:06 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 31 May 2011 13:06:11 +0000 (13:06 +0000)
Improve error message if an application is deployed with an incomplete FORM authentication configuration.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1129658 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/authenticator/FormAuthenticator.java
java/org/apache/catalina/authenticator/LocalStrings.properties
webapps/docs/changelog.xml

index 9dc3ed5..b484705 100644 (file)
@@ -365,9 +365,19 @@ public class FormAuthenticator
     protected void forwardToLoginPage(Request request,
             HttpServletResponse response, LoginConfig config)
             throws IOException {
+        
+        String loginPage = config.getLoginPage();
+        if (loginPage == null || loginPage.length() == 0) {
+            String msg = sm.getString("formAuthenticator.noLoginPage",
+                    context.getName());
+            log.warn(msg);
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                    msg);
+            return;
+        }
+        
         RequestDispatcher disp =
-            context.getServletContext().getRequestDispatcher
-            (config.getLoginPage());
+            context.getServletContext().getRequestDispatcher(loginPage);
         try {
             if (context.fireRequestInitEvent(request)) {
                 disp.forward(request.getRequest(), response);
@@ -398,6 +408,17 @@ public class FormAuthenticator
     protected void forwardToErrorPage(Request request,
             HttpServletResponse response, LoginConfig config)
             throws IOException {
+        
+        String errorPage = config.getErrorPage();
+        if (errorPage == null || errorPage.length() == 0) {
+            String msg = sm.getString("formAuthenticator.noErrorPage",
+                    context.getName());
+            log.warn(msg);
+            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                    msg);
+            return;
+        }
+
         RequestDispatcher disp =
             context.getServletContext().getRequestDispatcher
             (config.getErrorPage());
index fbdb397..98d68b6 100644 (file)
@@ -32,6 +32,8 @@ digestAuthenticator.cacheRemove=A valid entry has been removed from client nonce
  
 formAuthenticator.forwardErrorFail=Unexpected error forwarding to error page
 formAuthenticator.forwardLoginFail=Unexpected error forwarding to login page
+formAuthenticator.noErrorPage=No error page was defined for FORM authentication in context [{0}]
+formAuthenticator.noLoginPage=No login page was defined for FORM authentication in context [{0}]
 
 spnegoAuthenticator.authHeaderNoToken=The Negotiate authorization header sent by the client did not include a token
 spnegoAuthenticator.authHeaderNotNego=The authorization header sent by the client did not start with Negotiate
index e1380be..a837919 100644 (file)
         <bug>51274</bug>: Add missing i18n strings in PersistentManagerBase.
         Patch provided by Eiji Takahashi. (markt)
       </fix>
+      <fix>
+        <bug>51277</bug>: Improve error message if an application is deployed
+        with an incomplete FORM authentication configuration. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">