This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit d2a40f238d0ab6b6e60d643b208812aa6b655ca6 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Dec 5 20:00:02 2019 +0000 Clean-up prior to some refactoring. --- .../catalina/authenticator/FormAuthenticator.java | 51 ++++++++-------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/java/org/apache/catalina/authenticator/FormAuthenticator.java b/java/org/apache/catalina/authenticator/FormAuthenticator.java index 5b55664..d8551c4 100644 --- a/java/org/apache/catalina/authenticator/FormAuthenticator.java +++ b/java/org/apache/catalina/authenticator/FormAuthenticator.java @@ -168,22 +168,17 @@ public class FormAuthenticator if (log.isDebugEnabled()) { log.debug("Checking for reauthenticate in session " + session); } - String username = - (String) session.getNote(Constants.SESS_USERNAME_NOTE); - String password = - (String) session.getNote(Constants.SESS_PASSWORD_NOTE); - if ((username != null) && (password != null)) { + String username = (String) session.getNote(Constants.SESS_USERNAME_NOTE); + String password = (String) session.getNote(Constants.SESS_PASSWORD_NOTE); + if (username != null && password != null) { if (log.isDebugEnabled()) { log.debug("Reauthenticating username '" + username + "'"); } - principal = - context.getRealm().authenticate(username, password); + principal = context.getRealm().authenticate(username, password); if (principal != null) { session.setNote(Constants.FORM_PRINCIPAL_NOTE, principal); if (!matchRequest(request)) { - register(request, response, principal, - HttpServletRequest.FORM_AUTH, - username, password); + register(request, response, principal, HttpServletRequest.FORM_AUTH, username, password); return true; } } @@ -198,16 +193,13 @@ public class FormAuthenticator if (matchRequest(request)) { session = request.getSessionInternal(true); if (log.isDebugEnabled()) { - log.debug("Restore request from session '" - + session.getIdInternal() - + "'"); + log.debug("Restore request from session '" + session.getIdInternal() + "'"); } - principal = (Principal) - session.getNote(Constants.FORM_PRINCIPAL_NOTE); + principal = (Principal) session.getNote(Constants.FORM_PRINCIPAL_NOTE); register(request, response, principal, HttpServletRequest.FORM_AUTH, (String) session.getNote(Constants.SESS_USERNAME_NOTE), (String) session.getNote(Constants.SESS_PASSWORD_NOTE)); - // If we're caching principals we no longer need the username + // If we're caching principals we no longer need the user name // and password in the session, so remove them if (cache) { session.removeNote(Constants.SESS_USERNAME_NOTE); @@ -232,9 +224,7 @@ public class FormAuthenticator String requestURI = request.getDecodedRequestURI(); // Is this the action request from the login page? - boolean loginAction = - requestURI.startsWith(contextPath) && - requestURI.endsWith(Constants.FORM_ACTION); + boolean loginAction = requestURI.startsWith(contextPath) && requestURI.endsWith(Constants.FORM_ACTION); // No -- Save this request and redirect to the form login page if (!loginAction) { @@ -260,8 +250,7 @@ public class FormAuthenticator 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")); + response.sendError(HttpServletResponse.SC_FORBIDDEN, sm.getString("authenticator.requestBodyTooBig")); return false; } forwardToLoginPage(request, response, config); @@ -295,12 +284,11 @@ public class FormAuthenticator } if (session == null) { if (containerLog.isDebugEnabled()) { - containerLog.debug - ("User took so long to log on the session expired"); + containerLog.debug("User took so long to log on the session expired"); } if (landingPage == null) { - response.sendError(HttpServletResponse.SC_REQUEST_TIMEOUT, - sm.getString("authenticator.sessionExpired")); + response.sendError( + HttpServletResponse.SC_REQUEST_TIMEOUT, sm.getString("authenticator.sessionExpired")); } else { // Make the authenticator think the user originally requested // the landing page @@ -309,8 +297,7 @@ public class FormAuthenticator saved.setMethod("GET"); saved.setRequestURI(uri); saved.setDecodedRequestURI(uri); - request.getSessionInternal(true).setNote( - Constants.FORM_REQUEST_NOTE, saved); + request.getSessionInternal(true).setNote(Constants.FORM_REQUEST_NOTE, saved); response.sendRedirect(response.encodeRedirectURL(uri)); } return false; @@ -331,8 +318,7 @@ public class FormAuthenticator } if (requestURI == null) { if (landingPage == null) { - response.sendError(HttpServletResponse.SC_BAD_REQUEST, - sm.getString("authenticator.formlogin")); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, sm.getString("authenticator.formlogin")); } else { // Make the authenticator think the user originally requested // the landing page @@ -348,7 +334,6 @@ public class FormAuthenticator response.sendRedirect(response.encodeRedirectURL(requestURI)); } return false; - } @@ -514,8 +499,7 @@ public class FormAuthenticator } // Is there a saved request? - SavedRequest sreq = - (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE); + SavedRequest sreq = (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE); if (sreq == null) { return false; } @@ -549,8 +533,7 @@ public class FormAuthenticator throws IOException { // Retrieve and remove the SavedRequest object from our session - SavedRequest saved = (SavedRequest) - session.getNote(Constants.FORM_REQUEST_NOTE); + SavedRequest saved = (SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE); session.removeNote(Constants.FORM_REQUEST_NOTE); session.removeNote(Constants.FORM_PRINCIPAL_NOTE); if (saved == null) { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org