类 SessionUtils
java.lang.Object
cn.herodotus.stirrup.web.core.servlet.utils.SessionUtils
Description: Session 操作工具类
- 作者:
- : gengwei.zheng
- Date:
- : 2023/9/2 15:30
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StringanalyseSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest) 解析 Session IDstatic StringanalyseSessionId(org.springframework.http.HttpInputMessage httpInputMessage) 解析 Session IDstatic StringanalyseSessionId(org.springframework.http.server.ServerHttpRequest serverHttpRequest) 解析 Session IDstatic jakarta.servlet.http.HttpSessiongetSession(jakarta.servlet.http.HttpServletRequest httpServletRequest) 将 getSession 统一封装为一个方法,方便统一修改static jakarta.servlet.http.HttpSessiongetSession(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create) 将 getSession 统一封装为一个方法,方便统一修改static StringgetSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest) 获取 Session ID。static StringgetSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create) 获取 Session Id。static StringgetSessionIdFromHeader(org.springframework.http.HttpInputMessage httpInputMessage) 获取 Session IDstatic StringgetSessionIdFromHeader(org.springframework.http.server.ServerHttpRequest serverHttpRequest) 获取 Session IDstatic booleanisCryptoEnabled(jakarta.servlet.http.HttpServletRequest httpServletRequest, String sessionId) 判断基于 Session 的前后端数据加密是否开启static booleanisCryptoEnabled(org.springframework.http.HttpInputMessage httpInputMessage, String sessionId) 判断基于 Session 的前后端数据加密是否开启
-
构造器详细资料
-
SessionUtils
public SessionUtils()
-
-
方法详细资料
-
getSession
public static jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create) 将 getSession 统一封装为一个方法,方便统一修改- 参数:
httpServletRequest- httpServletRequestHttpServletRequestcreate- 是否创建新的 Session- 返回:
HttpSession
-
getSession
public static jakarta.servlet.http.HttpSession getSession(jakarta.servlet.http.HttpServletRequest httpServletRequest) 将 getSession 统一封装为一个方法,方便统一修改该方法默认不创建新的 getSession
- 参数:
httpServletRequest-HttpServletRequest- 返回:
HttpSessionor null
-
getSessionId
public static String getSessionId(jakarta.servlet.http.HttpServletRequest httpServletRequest, boolean create) 获取 Session Id。- 参数:
httpServletRequest-HttpServletRequestcreate- create 是否创建新的 Session- 返回:
- id 或者 null
-
getSessionId
获取 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
解析 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
解析 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-HttpServletRequestsessionId- SessionId- 返回:
- true 已开启,false 未开启。
-
isCryptoEnabled
public static boolean isCryptoEnabled(org.springframework.http.HttpInputMessage httpInputMessage, String sessionId) 判断基于 Session 的前后端数据加密是否开启- 参数:
httpInputMessage-HttpInputMessagesessionId- SessionId- 返回:
- true 已开启,false 未开启。
-