@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		logger.info("preHandle()");

		// Session management
		/*for (Cookie cookie : request.getCookies()) {
			logger.info("name of Cookie from request is: "+ cookie.getName());
			logger.info("value of Cookie form request is: "+ cookie.getValue());
		}*/ 

		if(request.getRequestURI().contains("/login.htm") || request.getRequestURI().contains("/logout.htm")){
			return super.preHandle(request, response, handler);
		}

		if(request.getSession()!=null)
		{
			UserAccount user=(UserAccount) request.getSession().getAttribute("userAccount");
			if(user!=null)
			{
				SessionPojo sessionPojo=sessionService.getSessionPojoFromService(user.getUsername());

				//ipcheck
				if(!request.getRemoteAddr().equals(sessionPojo.getIpAddress()))
				{
					logger.info("IpAddress Mismatch" + request.getRemoteAddr() + " "+sessionPojo.getIpAddress());
					response.sendRedirect(request.getContextPath() + "/resources/signout.jsp");
					return false;
				}

				//session Timeout check
				if(sessionPojo.getRecentActivityTime()>120)
				{
					logger.info("Session Timeout" + sessionPojo.getRecentActivityTime());
					request.getSession().invalidate();
					response.sendRedirect(request.getContextPath() + "/resources/signout.jsp");
					return false;
				}

				//step id check
				Cookie c= getStepIdCookie(request);
				
				if(c!=null)
				{
					if(c.getValue().equals(sessionPojo.getStepId())== false)
					{
						response.sendRedirect(request.getContextPath() + "/resources/signout.jsp");
						return false;
					}
				}
			}	
		}

		// Access control management
		if(AccessControlManager.canAccessThisResource(request) == false) {			
			response.sendRedirect(request.getContextPath() + "/resources/unauthorized.jsp");
			return false;
		}

		return super.preHandle(request, response, handler);
	}