svn commit: r1846221 - /ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1846221 - /ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java

jleroux@apache.org
Author: jleroux
Date: Fri Nov  9 09:32:56 2018
New Revision: 1846221

URL: http://svn.apache.org/viewvc?rev=1846221&view=rev
Log:
Improved: no functional change.

As annouced on dev ML removes unused code related to rememberMe.

I noticed this block of code in LoginEvents::storeLogin

        if ("Y".equals(request.getParameter("rememberMe"))) {
            setUsername(request, response);
        }

It was added by Andrew long ago: https://markmail.org/message/dmqqxse65inh6amr
But rememberMe is never created  in code so LoginEvents::setUsername is never used.
This removes this  block of code and the 2 related methods below.

Also automatically clean imports

Modified:
    ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java

Modified: ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java?rev=1846221&r1=1846220&r2=1846221&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/securityext/src/main/java/org/apache/ofbiz/securityext/login/LoginEvents.java Fri Nov  9 09:32:56 2018
@@ -26,7 +26,6 @@ import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 
-import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
@@ -56,10 +55,8 @@ import org.apache.ofbiz.product.store.Pr
 import org.apache.ofbiz.service.GenericServiceException;
 import org.apache.ofbiz.service.LocalDispatcher;
 import org.apache.ofbiz.service.ModelService;
-import org.apache.ofbiz.webapp.control.LoginWorker;
-
-import edu.emory.mathcs.backport.java.util.Arrays;
 import org.apache.ofbiz.service.ServiceUtil;
+import org.apache.ofbiz.webapp.control.LoginWorker;
 
 /**
  * LoginEvents - Events for UserLogin and Security handling.
@@ -417,47 +414,7 @@ public class LoginEvents {
         if (!"success".equals(responseString)) {
             return responseString;
         }
-        if ("Y".equals(request.getParameter("rememberMe"))) {
-            setUsername(request, response);
-        }
         // if we logged in okay, do the check store customer role
         return ProductEvents.checkStoreCustomerRole(request, response);
     }
-
-    public static String getUsername(HttpServletRequest request) {
-        String cookieUsername = null;
-        Cookie[] cookies = request.getCookies();
-        if (Debug.verboseOn()) {
-            Debug.logVerbose("Cookies:" + Arrays.toString(cookies), module);
-        }
-        if (cookies != null) {
-            for (Cookie cookie: cookies) {
-                if (cookie.getName().equals(usernameCookieName)) {
-                    cookieUsername = cookie.getValue();
-                    break;
-                }
-            }
-        }
-        return cookieUsername;
-    }
-
-    public static void setUsername(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
-        HttpSession session = request.getSession();
-        Delegator delegator = (Delegator) request.getAttribute("delegator");
-        String domain = EntityUtilProperties.getPropertyValue("url", "cookie.domain", delegator);
-        // first try to get the username from the cookie
-        synchronized (session) {
-            if (UtilValidate.isEmpty(getUsername(request))) {
-                // create the cookie and send it back
-                String usernameParam = URLEncoder.encode(request.getParameter("USERNAME"), "UTF-8");
-                Cookie cookie = new Cookie(usernameCookieName, usernameParam);
-                cookie.setMaxAge(60 * 60 * 24 * 365);
-                cookie.setPath("/");
-                cookie.setDomain(domain);
-                cookie.setSecure(true);
-                cookie.setHttpOnly(true);
-                response.addCookie(cookie);
-            }
-        }
-    }
 }