From: markt Date: Tue, 31 May 2011 13:06:11 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51277 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=eddba655fcf1d5d15875d745937c4ef769c4b0c4;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51277 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 --- diff --git a/java/org/apache/catalina/authenticator/FormAuthenticator.java b/java/org/apache/catalina/authenticator/FormAuthenticator.java index 9dc3ed51f..b48470505 100644 --- a/java/org/apache/catalina/authenticator/FormAuthenticator.java +++ b/java/org/apache/catalina/authenticator/FormAuthenticator.java @@ -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()); diff --git a/java/org/apache/catalina/authenticator/LocalStrings.properties b/java/org/apache/catalina/authenticator/LocalStrings.properties index fbdb397b9..98d68b6fa 100644 --- a/java/org/apache/catalina/authenticator/LocalStrings.properties +++ b/java/org/apache/catalina/authenticator/LocalStrings.properties @@ -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 diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index e1380be5f..a83791974 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -67,6 +67,10 @@ 51274: Add missing i18n strings in PersistentManagerBase. Patch provided by Eiji Takahashi. (markt) + + 51277: Improve error message if an application is deployed + with an incomplete FORM authentication configuration. (markt) +