类 SessionUtils

java.lang.Object
cn.herodotus.stirrup.web.core.servlet.utils.SessionUtils

public class SessionUtils extends Object

Description: Session 操作工具类

作者:
: gengwei.zheng
Date:
: 2023/9/2 15:30
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static String
    analyseSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest)
    解析 Session ID
    static String
    analyseSessionId(org.springframework.http.HttpInputMessage httpInputMessage)
    解析 Session ID
    static String
    analyseSessionId(org.springframework.http.server.ServerHttpRequest serverHttpRequest)
    解析 Session ID
    static jakarta.servlet.http.HttpSession
    getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest)
    将 getSession 统一封装为一个方法,方便统一修改
    static jakarta.servlet.http.HttpSession
    getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create)
    将 getSession 统一封装为一个方法,方便统一修改
    static String
    getSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest)
    获取 Session ID。
    static String
    getSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create)
    获取 Session Id。
    static String
    getSessionIdFromHeader(org.springframework.http.HttpInputMessage httpInputMessage)
    获取 Session ID
    static String
    getSessionIdFromHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest)
    获取 Session ID
    static boolean
    isCryptoEnabled(jakarta.servlet.http.HttpServletRequest httpServletRequest, String sessionId)
    判断基于 Session 的前后端数据加密是否开启
    static boolean
    isCryptoEnabled(org.springframework.http.HttpInputMessage httpInputMessage, String sessionId)
    判断基于 Session 的前后端数据加密是否开启

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • SessionUtils

      public SessionUtils()
  • 方法详细资料

    • getSession

      public static jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create)
      将 getSession 统一封装为一个方法,方便统一修改
      参数:
      httpServletRequest - httpServletRequest HttpServletRequest
      create - 是否创建新的 Session
      返回:
      HttpSession
    • getSession

      public static jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest)
      将 getSession 统一封装为一个方法,方便统一修改

      该方法默认不创建新的 getSession

      参数:
      httpServletRequest - HttpServletRequest
      返回:
      HttpSession or null
    • getSessionId

      public static String getSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create)
      获取 Session Id。
      参数:
      httpServletRequest - HttpServletRequest
      create - create 是否创建新的 Session
      返回:
      id 或者 null
    • getSessionId

      public static String getSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest)
      获取 Session ID。
      参数:
      httpServletRequest - HttpServletRequest
      返回:
      session ID 或者 null
    • getSessionIdFromHeader

      public static String getSessionIdFromHeader(org.springframework.http.HttpInputMessage httpInputMessage)
      获取 Session ID
      参数:
      httpInputMessage - HttpInputMessage
      返回:
      session ID 或者 null
    • getSessionIdFromHeader

      public static String getSessionIdFromHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest)
      获取 Session ID
      参数:
      serverHttpRequest - ServerHttpRequest
      返回:
      session ID 或者 null
    • analyseSessionId

      public static String analyseSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest)
      解析 Session ID

      如果请求中有 X_HERODOTUS_SESSION_ID 头,那么则返回 SessionId,意味着前后端加密有效。 这种处理方式,主要解决在没有使用系统 Session 的环境下,单独调用接口特别是测试接口时,提示 Session 过期的问题。

      参数:
      httpServletRequest - HttpServletRequest
      返回:
      session ID 或者 null
    • analyseSessionId

      public static String analyseSessionId(org.springframework.http.server.ServerHttpRequest serverHttpRequest)
      解析 Session ID

      如果请求中有 X_HERODOTUS_SESSION_ID 头,那么则返回 SessionId,意味着前后端加密有效。 这种处理方式,主要解决在没有使用系统 Session 的环境下,单独调用接口特别是测试接口时,提示 Session 过期的问题。

      参数:
      serverHttpRequest - ServerHttpRequest
      返回:
      session ID 或者 null
    • analyseSessionId

      public static String analyseSessionId(org.springframework.http.HttpInputMessage httpInputMessage)
      解析 Session ID

      如果请求中有 X_HERODOTUS_SESSION_ID 头,那么则返回 SessionId,意味着前后端加密有效。 这种处理方式,主要解决在没有使用系统 Session 的环境下,单独调用接口特别是测试接口时,提示 Session 过期的问题。

      参数:
      httpInputMessage - HttpInputMessage
      返回:
      session ID 或者 null
    • isCryptoEnabled

      public static boolean isCryptoEnabled(jakarta.servlet.http.HttpServletRequest httpServletRequest, String sessionId)
      判断基于 Session 的前后端数据加密是否开启
      参数:
      httpServletRequest - HttpServletRequest
      sessionId - SessionId
      返回:
      true 已开启,false 未开启。
    • isCryptoEnabled

      public static boolean isCryptoEnabled(org.springframework.http.HttpInputMessage httpInputMessage, String sessionId)
      判断基于 Session 的前后端数据加密是否开启
      参数:
      httpInputMessage - HttpInputMessage
      sessionId - SessionId
      返回:
      true 已开启,false 未开启。