Subversion Repositories SmartDukaan

Rev

Rev 2867 | Rev 2935 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2867 Rev 2907
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
3
import in.shop2020.model.v1.user.User;
3
import in.shop2020.model.v1.user.User;
4
import in.shop2020.model.v1.user.UserContextException;
4
import in.shop2020.model.v1.user.UserContextException;
-
 
5
import in.shop2020.serving.interceptors.UserInterceptor;
5
import in.shop2020.thrift.clients.UserContextServiceClient;
6
import in.shop2020.thrift.clients.UserContextServiceClient;
6
 
7
 
7
import java.io.Serializable;
8
import java.io.Serializable;
8
 
9
 
9
import org.apache.thrift.TException;
10
import org.apache.thrift.TException;
10
 
11
 
-
 
12
import com.google.gson.Gson;
-
 
13
 
11
/**
14
/**
12
 * This class is used to cache data that is frequently accessed for displaying
15
 * This class is used to cache data that is frequently accessed for displaying
13
 * on the pages of the site. It implements Serializable since
16
 * on the pages of the site. It implements Serializable since
14
 * <a href="http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html#Restart%20Persistence">Tomcat's restart persistence</a>
17
 * <a href="http://tomcat.apache.org/tomcat-5.5-doc/config/manager.html#Restart%20Persistence">Tomcat's restart persistence</a>
15
 * ensures that all session attributes will be preserved across application
18
 * ensures that all session attributes will be preserved across application
Line 171... Line 174...
171
 
174
 
172
	public void setPincode(String pincode) {
175
	public void setPincode(String pincode) {
173
		this.pincode = pincode;
176
		this.pincode = pincode;
174
	}
177
	}
175
 
178
 
-
 
179
	public static String getUserinfoCookieValueFromUserSessionInfo(UserSessionInfo userinfo){
-
 
180
		Gson gson = new Gson();
-
 
181
		return  UserInterceptor.desEncrypter.encrypt(gson.toJson(userinfo));
-
 
182
	}
-
 
183
	
-
 
184
	public static UserSessionInfo getUserSessionInfoFromCookieValue(String jsonString){
-
 
185
		Gson gson = new Gson();
-
 
186
		UserSessionInfo userinfo;
-
 
187
		try{
-
 
188
			userinfo = gson.fromJson(UserInterceptor.desEncrypter.decrypt(jsonString), UserSessionInfo.class);
-
 
189
		}catch (Exception e) {
-
 
190
			userinfo = new UserSessionInfo();
-
 
191
			//FIXME Remove the old cookies
-
 
192
		}
-
 
193
		return userinfo;
-
 
194
	}
-
 
195
	
176
	@Override
196
	@Override
177
	public String toString() {
197
	public String toString() {
178
		return "UserSessionInfo [isLoggedIn=" + isLoggedIn + ", userId="
198
		return "UserSessionInfo [isLoggedIn=" + isLoggedIn + ", userId="
179
				+ userId + ", email=" + email + ", nameOfUser=" + nameOfUser
199
				+ userId + ", email=" + email + ", nameOfUser=" + nameOfUser
180
				+ ", totalItems=" + totalItems + ", cartId=" + cartId
200
				+ ", totalItems=" + totalItems + ", cartId=" + cartId