Package com.freewebsys.blog.pojo

Examples of com.freewebsys.blog.pojo.UserInfo


    if (url.indexOf("/admin") == 0 && url.indexOf(".do") > 0
        && url.indexOf("/admin/userLogin") != 0
        && url.indexOf("/admin/userLogout") != 0) {

      // 获得session.
      UserInfo userInfo = (UserInfo) httpRequest.getSession()
          .getAttribute(GlobalConf.USER_SESSION);

      // System.out.println(userInfo);
      Cookie cookies[] = httpRequest.getCookies();
      Cookie c = null;
      String loginName = "";
      String rememberMe = "";
      for (int i = 0; cookies != null && i < cookies.length; i++) {
        c = cookies[i];
        if (c.getName().equals("loginName")) {
          loginName = c.getValue();
        }
        if (c.getName().equals("rememberme")) {
          rememberMe = c.getValue();
        }
      }
      if (userInfo == null) {// 用户没有登录跳转到登录页面.
        if (StringUtils.isNotBlank(loginName)
            && StringUtils.isNotBlank(rememberMe)) {

          ServletContext context = httpRequest.getSession()
              .getServletContext();
          ApplicationContext applicationContext = WebApplicationContextUtils
              .getWebApplicationContext(context);
          // 从spring中获得服务
          UserInfoService userInfoService = (UserInfoService) applicationContext
              .getBean("userInfoService");

          UserInfo userInfoTemp = userInfoService
              .getUserInfoByRememberMe(loginName, rememberMe);
          if (userInfoTemp != null) {
            httpRequest.getSession().setAttribute(
                GlobalConf.USER_SESSION, userInfoTemp);
            // 如果教研成功就更新记住我的key.更安全.
            String remembermeKey = userInfoService
                .updateUserInfoRememberMe(userInfoTemp.getId());
            Cookie cookie = new Cookie("rememberme", remembermeKey);
            cookie.setMaxAge(60 * 60 * 24 * 30);
            httpResponse.addCookie(cookie);
            cookie = new Cookie("loginName",
                userInfoTemp.getLoginName());
            cookie.setMaxAge(60 * 60 * 24 * 30);
            httpResponse.addCookie(cookie);
            chain.doFilter(request, httpResponse);
            return;
          }
View Full Code Here

TOP

Related Classes of com.freewebsys.blog.pojo.UserInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.