cn.antcore.security.request.HttpSecurityServletRequestWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-security Show documentation
Show all versions of spring-boot-starter-security Show documentation
This is spring-boot-starter-security.
The newest version!
package cn.antcore.security.request;
import cn.antcore.security.session.SessionStrategy;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Request包装类, 生成自定义Session
*
* Created by Hong.
* 2021/3/24
**/
public class HttpSecurityServletRequestWrapper extends HttpServletRequestWrapper {
private HttpSession session;
public HttpSecurityServletRequestWrapper(HttpServletRequest request, HttpServletResponse response, SessionStrategy sessionStrategy) {
super(request);
if (sessionStrategy != null) {
this.session = sessionStrategy.getSession(request, response);
return;
}
this.session = super.getSession();
}
@Override
public HttpSession getSession() {
return session;
}
@Override
public HttpSession getSession(boolean create) {
return this.getSession();
}
@Override
public String getRequestedSessionId() {
return this.session.getId();
}
}