| Line 3... |
Line 3... |
| 3 |
import java.util.Map;
|
3 |
import java.util.Map;
|
| 4 |
|
4 |
|
| 5 |
import in.shop2020.model.v1.user.User;
|
5 |
import in.shop2020.model.v1.user.User;
|
| 6 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
6 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
| 7 |
import in.shop2020.serving.services.UserSessionInfo;
|
7 |
import in.shop2020.serving.services.UserSessionInfo;
|
| - |
|
8 |
import in.shop2020.serving.utils.DesEncrypter;
|
| 8 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
9 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
| 9 |
|
10 |
|
| 10 |
import javax.servlet.http.Cookie;
|
11 |
import javax.servlet.http.Cookie;
|
| 11 |
import javax.servlet.http.HttpServletRequest;
|
12 |
import javax.servlet.http.HttpServletRequest;
|
| 12 |
import javax.servlet.http.HttpServletResponse;
|
13 |
import javax.servlet.http.HttpServletResponse;
|
| Line 24... |
Line 25... |
| 24 |
private static final long serialVersionUID = -4125815700236506235L;
|
25 |
private static final long serialVersionUID = -4125815700236506235L;
|
| 25 |
private static Logger log = Logger.getLogger(CreateUserInterceptor.class);
|
26 |
private static Logger log = Logger.getLogger(CreateUserInterceptor.class);
|
| 26 |
private Map<String, Cookie> cookiesMap = null;
|
27 |
private Map<String, Cookie> cookiesMap = null;
|
| 27 |
private Cookie userCookie = null;
|
28 |
private Cookie userCookie = null;
|
| 28 |
private String cookieDomain = "";
|
29 |
private String cookieDomain = "";
|
| - |
|
30 |
private DesEncrypter desEncrypter = new DesEncrypter(UserInterceptor.COOKIE_DECRYPTION_STRING);
|
| 29 |
|
31 |
|
| 30 |
public void setCookieDomain(String cookieDomain) {
|
32 |
public void setCookieDomain(String cookieDomain) {
|
| 31 |
this.cookieDomain = cookieDomain;
|
33 |
this.cookieDomain = cookieDomain;
|
| 32 |
}
|
34 |
}
|
| 33 |
|
35 |
|
| Line 61... |
Line 63... |
| 61 |
}
|
63 |
}
|
| 62 |
|
64 |
|
| 63 |
|
65 |
|
| 64 |
private void createUserCookie(long userId, boolean force) {
|
66 |
private void createUserCookie(long userId, boolean force) {
|
| 65 |
userCookie = (Cookie) cookiesMap.get(UserInterceptor.USER_ID_COOKIE_NAME);
|
67 |
userCookie = (Cookie) cookiesMap.get(UserInterceptor.USER_ID_COOKIE_NAME);
|
| 66 |
String encryptedUserId = UserInterceptor.desEncrypter.encrypt(userId + "");
|
68 |
String encryptedUserId = desEncrypter.encrypt(userId + "");
|
| 67 |
if(force || userCookie == null || !(encryptedUserId + "").equals(userCookie.getValue())){
|
69 |
if(force || userCookie == null || !(encryptedUserId + "").equals(userCookie.getValue())){
|
| 68 |
userCookie = new Cookie(UserInterceptor.USER_ID_COOKIE_NAME, encryptedUserId);
|
70 |
userCookie = new Cookie(UserInterceptor.USER_ID_COOKIE_NAME, encryptedUserId);
|
| 69 |
userCookie.setMaxAge(UserInterceptor.SECONDS_IN_YEAR); // one year
|
71 |
userCookie.setMaxAge(UserInterceptor.SECONDS_IN_YEAR); // one year
|
| 70 |
userCookie.setPath("/");
|
72 |
userCookie.setPath("/");
|
| 71 |
if(!cookieDomain.isEmpty()) {
|
73 |
if(!cookieDomain.isEmpty()) {
|