Subversion Repositories SmartDukaan

Rev

Rev 719 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 719 Rev 745
Line 73... Line 73...
73
	}
73
	}
74
	
74
	
75
	@Override
75
	@Override
76
	public void setServletRequest(HttpServletRequest request){
76
	public void setServletRequest(HttpServletRequest request){
77
		this.request = request;
77
		this.request = request;
78
		log.info("REQUESTED URL: " + request.getRequestURL().toString());
78
//		log.debug("REQUESTED URL: " + request.getRequestURL().toString());
79
		log.info("Remote host "+ request.getRemoteHost());
79
//		log.debug("Remote host "+ request.getRemoteHost());
80
		log.info("requested Session Id "+ request.getRequestedSessionId());
80
//		log.debug("requested Session Id "+ request.getRequestedSessionId());
81
		log.info("Session Id "+ request.getSession().getId());
81
//		log.debug("Session Id "+ request.getSession().getId());
82
		log.info("QUERY STRING IS: " + this.request.getQueryString());
82
//		log.debug("QUERY STRING IS: " + this.request.getQueryString());
83
		
83
//		
84
		 Enumeration names = request.getHeaderNames();
84
//		Enumeration names = request.getHeaderNames();
85
		    while (names.hasMoreElements()) {
85
//	    while (names.hasMoreElements()) {
86
		      String name = (String) names.nextElement();
86
//	      String name = (String) names.nextElement();
87
		      Enumeration values = request.getHeaders(name);  // support multiple values
87
//	      Enumeration values = request.getHeaders(name);  // support multiple values
88
		      if (values != null) {
88
//	      if (values != null) {
89
		        while (values.hasMoreElements()) {
89
//	        while (values.hasMoreElements()) {
90
		          String value = (String) values.nextElement();
90
//	          String value = (String) values.nextElement();
91
		          log.info(name + ": " + value);
91
//	          log.debug(name + ": " + value);
92
		        }
92
//	        }
93
		      }
93
//	      }
94
		    }
94
//	    }
95
		
95
//		
96
		for(Object param: request.getParameterMap().keySet()){
96
//		for(Object param: request.getParameterMap().keySet()){
97
			log.info("PARAMS: " + param + " = "+ request.getParameter((String)param));
97
//			log.debug("PARAMS: " + param + " = "+ request.getParameter((String)param));
98
		}
98
//		}
99
		
-
 
100
		
99
		
101
		this.session = request.getSession();	// Get the existing session or create a new one
100
		this.session = request.getSession();	// Get the existing session or create a new one
102
		getCookiesMap(request);
101
		getCookiesMap(request);
103
		String requestedSessionId = request.getRequestedSessionId();
102
		String requestedSessionId = request.getRequestedSessionId();
104
		
103
		
Line 131... Line 130...
131
		for (Cookie cookie : cookies)
130
		for (Cookie cookie : cookies)
132
			cookiesMap.put(cookie.getName(), cookie);
131
			cookiesMap.put(cookie.getName(), cookie);
133
	}
132
	}
134
 
133
 
135
	private void setUserSessionInfo(String jsessionid){
134
	private void setUserSessionInfo(String jsessionid){
136
		log.info("Inside SetUserSessionInfo 1");
-
 
137
		this.userinfo = (UserSessionInfo) this.session.getAttribute("userinfo");
135
		this.userinfo = (UserSessionInfo) this.session.getAttribute("userinfo");
138
		if(this.userinfo == null || this.userinfo.getUserId() == -1){
136
		if(this.userinfo == null || this.userinfo.getUserId() == -1){
139
			log.info("Inside SetUserSessionInfo 2");
-
 
140
			this.userinfo = new UserSessionInfo(jsessionid);
137
			this.userinfo = new UserSessionInfo(jsessionid);
141
			this.session.setAttribute("userinfo", this.userinfo);
138
			this.session.setAttribute("userinfo", this.userinfo);
142
		}
139
		}
143
	}
140
	}
144
 
141
 
145
	protected void createUserCookie(long userId, boolean force) {
142
	protected void createUserCookie(long userId, boolean force) {
146
		log.info("Inside CreateUserCookie 1");
-
 
147
		userCookie = (Cookie) cookiesMap.get("uid");
143
		userCookie = (Cookie) cookiesMap.get("uid");
148
		if(force || userCookie == null || !(userId + "").equals(userCookie.getValue())){
144
		if(force || userCookie == null || !(userId + "").equals(userCookie.getValue())){
149
			log.info("Inside CreateUserCookie 2");
-
 
150
			String encryptedUserId = desEncrypter.encrypt(userId + "");  
145
			String encryptedUserId = desEncrypter.encrypt(userId + "");  
151
			userCookie = new Cookie("uid", encryptedUserId);
146
			userCookie = new Cookie("uid", encryptedUserId);
152
		}
147
		}
153
	}
148
	}
154
	
149
	
Line 168... Line 163...
168
		}
163
		}
169
		if(this.userinfo==null)
164
		if(this.userinfo==null)
170
			setUserSessionInfo(jsessionid);
165
			setUserSessionInfo(jsessionid);
171
	}
166
	}
172
	
167
	
173
//	private void processCookiesInfo(){
-
 
174
//		Cookie[] cookies = this.request.getCookies();
-
 
175
//		boolean foundUserIdCookie = false;
-
 
176
//		boolean foundSessionIdCookie = false;
-
 
177
//		long userId = 0 ;
-
 
178
//		long sessionId = 0;
-
 
179
//		
-
 
180
//		if(cookies != null){
-
 
181
//		    for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++) { 
-
 
182
//		        Cookie cookie1 = cookies[loopIndex];
-
 
183
//		        if (cookie1.getName().equals("userid")) {
-
 
184
//		            System.out.println("User Id is = " + cookie1.getValue());
-
 
185
//		            userId = Long.parseLong(cookie1.getValue());
-
 
186
//		            foundUserIdCookie = true;
-
 
187
//		        }
-
 
188
//		        if (cookie1.getName().equals("sessionid")) {
-
 
189
//		            System.out.println("Session Id is = " + cookie1.getValue());
-
 
190
//		            sessionId = Long.parseLong(cookie1.getValue());
-
 
191
//		            foundSessionIdCookie = true;
-
 
192
//		        }
-
 
193
//	    	}
-
 
194
//		}
-
 
195
//	
-
 
196
//		if(foundUserIdCookie){
-
 
197
//			if(Utils.isUserLoggedIn(userId)){
-
 
198
//				userinfo = new UserSessionInfo(userId, false);
-
 
199
//				
-
 
200
//			}
-
 
201
//			else{
-
 
202
//				if(foundSessionIdCookie){
-
 
203
//					userinfo = new UserSessionInfo(sessionId, true);	
-
 
204
//				}else{
-
 
205
//					userinfo = new UserSessionInfo();
-
 
206
//				    for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++) { 
-
 
207
//				        Cookie cookie1 = cookies[loopIndex];
-
 
208
//				        if (cookie1.getName().equals("userid")) {
-
 
209
//				        	cookie1.setMaxAge(0);
-
 
210
//				        	//cookie1.setPath(cookie1.getPath());
-
 
211
//							//cookie1.setDomain(cookie1.getDomain());
-
 
212
//				        	tempCookie = cookie1;
-
 
213
//				        }
-
 
214
//					}
-
 
215
//				}
-
 
216
//			}
-
 
217
//		}			
-
 
218
//		else{  
-
 
219
//			if(foundSessionIdCookie){
-
 
220
//				userinfo = new UserSessionInfo(sessionId, true);			
-
 
221
//			}
-
 
222
//			else{
-
 
223
//				userinfo = new UserSessionInfo();
-
 
224
//				//Cookie cookie1 = new Cookie("sessionid", userinfo.getSessionId()+"");
-
 
225
//		    	//tempCookie = cookie1;
-
 
226
//			}
-
 
227
//		}
-
 
228
//	}
-
 
229
	
-
 
230
	public UserSessionInfo getUserInfo(){
168
	public UserSessionInfo getUserInfo(){
231
		return this.userinfo;
169
		return this.userinfo;
232
	}
170
	}
233
 
171
 
234
	public String getHeaderSnippet(){
172
	public String getHeaderSnippet(){
Line 275... Line 213...
275
	}
213
	}
276
	
214
	
277
	public void resetRedirectUrl(){
215
	public void resetRedirectUrl(){
278
		this.request.getSession().removeAttribute("REDIRECT_URL");
216
		this.request.getSession().removeAttribute("REDIRECT_URL");
279
	}
217
	}
280
 
-
 
281
}
218
}
282
 
-
 
283
219