You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2021/11/15 14:23:56 UTC

[jspwiki] 06/14: add format + use log placeholders

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit db6ab5092aaba27802ebd50ece2ea866eb7e35d2
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Mon Nov 15 14:31:37 2021 +0100

    add format + use log placeholders
---
 jspwiki-war/src/main/webapp/Login.jsp | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Login.jsp b/jspwiki-war/src/main/webapp/Login.jsp
index d207242..02c55e8 100644
--- a/jspwiki-war/src/main/webapp/Login.jsp
+++ b/jspwiki-war/src/main/webapp/Login.jsp
@@ -98,41 +98,35 @@
         }
 
         // If using custom auth, we need to do the login now
-
         String action = request.getParameter("action");
         if( request.getParameter("submitlogin") != null ) {
             String uid    = request.getParameter( "j_username" );
             String passwd = request.getParameter( "j_password" );
-            log.debug( "Attempting to authenticate user " + uid );
+            log.debug( "Attempting to authenticate user {}", uid );
 
             // Log the user in!
             if ( mgr.login( wikiSession, request, uid, passwd ) ) {
-                log.info( "Successfully authenticated user " + uid + " (custom auth)" );
+                log.info( "Successfully authenticated user {} (custom auth)", uid );
             } else {
-                log.info( "Failed to authenticate user " + uid );
-                wikiSession.addMessage( "login", rb.getString("login.error.password") );
+                log.info( "Failed to authenticate user {}", uid );
+                wikiSession.addMessage( "login", rb.getString( "login.error.password" ) );
             }
         }
     } else {
-        //
         //  Have we already been submitted?  If yes, then we can assume that we have been logged in before.
-        //
-        Object seen = session.getAttribute("_redirect");
+        Object seen = session.getAttribute( "_redirect" );
         if( seen != null ) {
-            response.sendError( HttpServletResponse.SC_FORBIDDEN, rb.getString("login.error.noaccess") );
-            session.removeAttribute("_redirect");
+            response.sendError( HttpServletResponse.SC_FORBIDDEN, rb.getString( "login.error.noaccess" ) );
+            session.removeAttribute( "_redirect" );
             return;
         }
-        session.setAttribute("_redirect","I love Outi"); // Just any marker will do
-
-        // If using container auth, the container will have automatically
-        // attempted to log in the user before Login.jsp was loaded.
-        // Thus, if we got here, the container must have authenticated
-        // the user already. All we do is simply record that fact.
-        // Nice and easy.
+        session.setAttribute( "_redirect","I love Outi" ); // Just any marker will do
 
+        // If using container auth, the container will have automatically attempted to log in the user before
+        // Login.jsp was loaded. Thus, if we got here, the container must have authenticated the user already.
+        // All we do is simply record that fact. Nice and easy.
         Principal user = wikiSession.getLoginPrincipal();
-        log.info( "Successfully authenticated user " + user.getName() + " (container auth)" );
+        log.info( "Successfully authenticated user {} (container auth)", user.getName() );
     }
 
     // If user logged in, set the user cookie with the wiki principal's name.
@@ -159,7 +153,7 @@
         String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
 
         // Redirect!
-        log.info( "Redirecting user to " + viewUrl );
+        log.info( "Redirecting user to {}", viewUrl );
         response.sendRedirect( viewUrl );
         return;
     }