コード例 #1
0
ファイル: AuthHelper.java プロジェクト: Gapelia/stage1
 public static boolean isSessionAvailable(HttpServletRequest request) {
   if ("true".equals((String) request.getSession().getAttribute("login"))) return true;
   Cookie[] cookies = request.getCookies();
   if (null == cookies) {
     return false;
   }
   for (Cookie cookie : cookies) {
     if ("JSESSIONID".equals(cookie.getName())) {
       String sessionId = cookie.getValue();
       HttpSession oldSession = SessionManager.find(sessionId);
       HttpSession newSession = request.getSession();
       boolean previousLogin = false;
       if (null != oldSession && null != oldSession.getAttribute("profile")) {
         newSession.setAttribute("profile", oldSession.getAttribute("profile"));
       }
       if (null != oldSession && null != oldSession.getAttribute("login")) {
         newSession.setAttribute("login", oldSession.getAttribute("login"));
         previousLogin = true;
       }
       if (previousLogin) {
         return true;
       }
       break;
     }
   }
   return false;
 }
コード例 #2
0
ファイル: AuthHelper.java プロジェクト: Gapelia/stage1
 public static Profile getUserProfileFromSessionId(String sessionId) {
   LOG.info("Session Id received: " + sessionId);
   HttpSession session = SessionManager.find(sessionId);
   if (session == null) {
     LOG.error("No session found with id: " + sessionId);
     return null;
   }
   Profile profile = (Profile) session.getAttribute("profile");
   if (profile == null) {
     LOG.error("No profile found in session: " + sessionId);
     return null;
   }
   return profile;
 }