| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import in.shop2020.serving.interceptors.UserAware;
|
3 |
import in.shop2020.serving.interceptors.UserAware;
|
| 4 |
import in.shop2020.serving.interceptors.UserInterceptor;
|
4 |
import in.shop2020.serving.interceptors.UserInterceptor;
|
| 5 |
import in.shop2020.serving.services.PageLoaderHandler;
|
5 |
import in.shop2020.serving.services.PageLoaderHandler;
|
| 6 |
import in.shop2020.serving.services.UserSessionInfo;
|
6 |
import in.shop2020.serving.services.UserSessionInfo;
|
| - |
|
7 |
import in.shop2020.serving.utils.DesEncrypter;
|
| 7 |
|
8 |
|
| 8 |
import java.util.ArrayList;
|
9 |
import java.util.ArrayList;
|
| 9 |
import java.util.HashMap;
|
10 |
import java.util.HashMap;
|
| 10 |
import java.util.List;
|
11 |
import java.util.List;
|
| 11 |
import java.util.Map;
|
12 |
import java.util.Map;
|
| Line 37... |
Line 38... |
| 37 |
protected HttpServletRequest request;
|
38 |
protected HttpServletRequest request;
|
| 38 |
protected HttpSession session;
|
39 |
protected HttpSession session;
|
| 39 |
protected String domainName;
|
40 |
protected String domainName;
|
| 40 |
protected UserSessionInfo userinfo = null;
|
41 |
protected UserSessionInfo userinfo = null;
|
| 41 |
private static Logger log = Logger.getLogger(Class.class);
|
42 |
private static Logger log = Logger.getLogger(Class.class);
|
| - |
|
43 |
private DesEncrypter desEncrypter = new DesEncrypter(UserInterceptor.COOKIE_DECRYPTION_STRING);
|
| 42 |
|
44 |
|
| 43 |
protected Cookie userCookie = null;
|
45 |
protected Cookie userCookie = null;
|
| 44 |
|
46 |
|
| 45 |
protected Map<String, String> htmlSnippets;
|
47 |
protected Map<String, String> htmlSnippets;
|
| 46 |
|
48 |
|
| 47 |
PageLoaderHandler pageLoader = null;
|
49 |
PageLoaderHandler pageLoader = null;
|
| Line 51... |
Line 53... |
| 51 |
htmlSnippets = new HashMap<String, String>();
|
53 |
htmlSnippets = new HashMap<String, String>();
|
| 52 |
}
|
54 |
}
|
| 53 |
|
55 |
|
| 54 |
@Override
|
56 |
@Override
|
| 55 |
public void setCookiesMap(Map<String, Cookie> cookiesMap) {
|
57 |
public void setCookiesMap(Map<String, Cookie> cookiesMap) {
|
| 56 |
log.info("Received cookiesMap and it is " + cookiesMap);
|
58 |
log.info("Received cookiesMap.");
|
| 57 |
this.cookiesMap = cookiesMap;
|
59 |
this.cookiesMap = cookiesMap;
|
| 58 |
}
|
60 |
}
|
| 59 |
|
61 |
|
| 60 |
@Override
|
62 |
@Override
|
| 61 |
public void setServletResponse(HttpServletResponse response) {
|
63 |
public void setServletResponse(HttpServletResponse response) {
|
| Line 127... |
Line 129... |
| 127 |
userinfoCookie.setDomain(domainName);
|
129 |
userinfoCookie.setDomain(domainName);
|
| 128 |
cookiesMap.put(UserInterceptor.USER_INFO_COOKIE_NAME, userinfoCookie);
|
130 |
cookiesMap.put(UserInterceptor.USER_INFO_COOKIE_NAME, userinfoCookie);
|
| 129 |
cookies.add(userinfoCookie);
|
131 |
cookies.add(userinfoCookie);
|
| 130 |
}
|
132 |
}
|
| 131 |
Cookie userCookie = cookiesMap.get(UserInterceptor.USER_ID_COOKIE_NAME);
|
133 |
Cookie userCookie = cookiesMap.get(UserInterceptor.USER_ID_COOKIE_NAME);
|
| 132 |
String encryptedUserId = UserInterceptor.desEncrypter.encrypt(userId + "");
|
134 |
String encryptedUserId = desEncrypter.encrypt(userId + "");
|
| 133 |
if(userCookie == null || !(encryptedUserId + "").equals(userCookie.getValue())){
|
135 |
if(userCookie == null || !(encryptedUserId + "").equals(userCookie.getValue())){
|
| 134 |
userinfoCookie = new Cookie(UserInterceptor.USER_ID_COOKIE_NAME, encryptedUserId);
|
136 |
userinfoCookie = new Cookie(UserInterceptor.USER_ID_COOKIE_NAME, encryptedUserId);
|
| 135 |
userinfoCookie.setMaxAge(UserInterceptor.SECONDS_IN_YEAR); // one year
|
137 |
userinfoCookie.setMaxAge(UserInterceptor.SECONDS_IN_YEAR); // one year
|
| 136 |
userinfoCookie.setPath("/");
|
138 |
userinfoCookie.setPath("/");
|
| 137 |
userinfoCookie.setDomain(domainName);
|
139 |
userinfoCookie.setDomain(domainName);
|