Author: markt
Date: Fri Jul 3 19:23:18 2015
New Revision: 1689071
URL: http://svn.apache.org/r1689071
Log:
Extracted login and non-login actions
Patch by fjodorver
Modified:
tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java
Modified:
tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java?rev=1689071&r1=1689070&r2=1689071&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java
(original)
+++
tomcat/trunk/java/org/apache/catalina/authenticator/jaspic/provider/modules/FormAuthModule.java
Fri Jul 3 19:23:18 2015
@@ -182,27 +182,54 @@ public class FormAuthModule extends Tomc
boolean loginAction = requestURI.startsWith(contextPath)
&& requestURI.endsWith(Constants.FORM_ACTION);
- // No -- Save this request and redirect to the form login page
if (!loginAction) {
- session = request.getSessionInternal(true);
- if (log.isDebugEnabled()) {
- log.debug("Save request in session '" +
session.getIdInternal() + "'");
- }
- try {
- saveRequest(request, session);
- } catch (IOException ioe) {
- log.debug("Request body too big to save during
authentication");
- response.sendError(HttpServletResponse.SC_FORBIDDEN,
- sm.getString("authenticator.requestBodyTooBig"));
- return AuthStatus.FAILURE;
- }
- forwardToLoginPage(request, response);
- return AuthStatus.SEND_CONTINUE;
- }
-
- // Yes -- Acknowledge the request, validate the specified
- // credentials
- // and redirect to the error page if they are not correct
+ return handleNoLoginAction(request, response);
+ }
+
+ return handleLoginAction(request, response);
+ }
+
+
+ /**
+ * Save this request and redirect to the form login page
+ *
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ */
+ private AuthStatus handleNoLoginAction(Request request,
HttpServletResponse response)
+ throws IOException {
+ Session session = request.getSessionInternal(true);
+ if (log.isDebugEnabled()) {
+ log.debug("Save request in session '" + session.getIdInternal() +
"'");
+ }
+ try {
+ saveRequest(request, session);
+ } catch (IOException ioe) {
+ log.debug("Request body too big to save during authentication");
+ response.sendError(HttpServletResponse.SC_FORBIDDEN,
+ sm.getString("authenticator.requestBodyTooBig"));
+ return AuthStatus.FAILURE;
+ }
+
+ forwardToLoginPage(request, response);
+ return AuthStatus.SEND_CONTINUE;
+ }
+
+
+ /**
+ * Acknowledge the request, validate the specified and redirect to the
error
+ * page if they are not correct
+ *
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ */
+ private AuthStatus handleLoginAction(Request request, HttpServletResponse
response)
+ throws IOException {
+
request.getResponse().sendAcknowledgement();
// TODO fix character encoding
@@ -215,7 +242,7 @@ public class FormAuthModule extends Tomc
if (log.isDebugEnabled()) {
log.debug("Authenticating username '" + username + "'");
}
- principal = realm.authenticate(username, password);
+ Principal principal = realm.authenticate(username, password);
if (principal == null) {
forwardToErrorPage(request, response);
return AuthStatus.FAILURE;
@@ -225,9 +252,7 @@ public class FormAuthModule extends Tomc
log.debug("Authentication of '" + username + "' was successful");
}
- if (session == null) {
- session = request.getSessionInternal(false);
- }
+ Session session = request.getSessionInternal(false);
if (session == null) {
handleSessionExpired(request, response);
return AuthStatus.FAILURE;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]