*/
protected String characterEncoding = null;
+ /**
+ * Landing page to use if a user tries to access the login page directly or
+ * if the session times out during login. If not set, error responses will
+ * be sent instead.
+ */
+ protected String landingPage = null;
// ------------------------------------------------------------- Properties
}
+ /**
+ * Return the landing page to use when FORM auth is mis-used.
+ */
+ public String getLandingPage() {
+ return landingPage;
+ }
+
+
+ /**
+ * Set the landing page to use when the FORM auth is mis-used.
+ */
+ public void setLandingPage(String landingPage) {
+ this.landingPage = landingPage;
+ }
+
+
// --------------------------------------------------------- Public Methods
if (containerLog.isDebugEnabled())
containerLog.debug
("User took so long to log on the session expired");
- response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT,
- sm.getString("authenticator.sessionExpired"));
+ if (landingPage == null) {
+ response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT,
+ sm.getString("authenticator.sessionExpired"));
+ } else {
+ // Make the authenticator think the user originally requested
+ // the landing page
+ String uri = request.getContextPath() + landingPage;
+ SavedRequest saved = new SavedRequest();
+ saved.setRequestURI(uri);
+ request.getSessionInternal(true).setNote(
+ Constants.FORM_REQUEST_NOTE, saved);
+ response.sendRedirect(response.encodeRedirectURL(uri));
+ }
return (false);
}
if (log.isDebugEnabled())
log.debug("Redirecting to original '" + requestURI + "'");
if (requestURI == null)
- response.sendError(HttpServletResponse.SC_BAD_REQUEST,
- sm.getString("authenticator.formlogin"));
+ if (landingPage == null) {
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST,
+ sm.getString("authenticator.formlogin"));
+ } else {
+ // Make the authenticator think the user originally requested
+ // the landing page
+ String uri = request.getContextPath() + landingPage;
+ SavedRequest saved = new SavedRequest();
+ saved.setRequestURI(uri);
+ session.setNote(Constants.FORM_REQUEST_NOTE, saved);
+ response.sendRedirect(response.encodeRedirectURL(uri));
+ }
else
response.sendRedirect(response.encodeRedirectURL(requestURI));
return (false);
workaround for browser caching issues. If not set, the default value of
<code>true</code> will be used.</p>
</attribute>
+
+ <attribute name="landingPage" required="false">
+ <p>Controls the behavior of the FORM authentication process if the
+ process is misused, for example by directly requesting the login page
+ or delaying logging in for so long that the session expires. If this
+ attribute is set, rather than returning an error response code, Tomcat
+ will redirect the user to the specified landing page if the login form
+ is submitted with valid credentials. For the login to be processed, the
+ landing page must be a protected resource (i.e. one that requires
+ authentication). If the landing page does not require authentication
+ then the user will not be logged in and will be prompted for their
+ credentials again when they access a protected page.</p>
+ </attribute>
<attribute name="securePagesWithPragma" required="false">
<p>Controls the caching of pages that are protected by security