Removed repeated downcasting of ServletRequest and ServletResponse
This commit is contained in:
parent
b2799985f2
commit
edd7bbeceb
|
@ -184,8 +184,15 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
|
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
|
||||||
ServletException {
|
ServletException {
|
||||||
|
|
||||||
|
Assert.isInstanceOf(HttpServletRequest.class, req, "ServletRequest must be an instance of HttpServletRequest");
|
||||||
|
Assert.isInstanceOf(HttpServletResponse.class, res, "ServletResponse must be an instance of HttpServletResponse");
|
||||||
|
|
||||||
|
HttpServletRequest request = (HttpServletRequest) req;
|
||||||
|
HttpServletResponse response = (HttpServletResponse) res;
|
||||||
|
|
||||||
if (request.getAttribute(FILTER_APPLIED) != null) {
|
if (request.getAttribute(FILTER_APPLIED) != null) {
|
||||||
// ensure that filter is only applied once per request
|
// ensure that filter is only applied once per request
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
|
@ -196,7 +203,7 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
HttpSession httpSession = null;
|
HttpSession httpSession = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpSession = ((HttpServletRequest) request).getSession(forceEagerSessionCreation);
|
httpSession = request.getSession(forceEagerSessionCreation);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ignored) {
|
catch (IllegalStateException ignored) {
|
||||||
}
|
}
|
||||||
|
@ -230,7 +237,7 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
// See SEC-398
|
// See SEC-398
|
||||||
|
|
||||||
OnRedirectUpdateSessionResponseWrapper responseWrapper =
|
OnRedirectUpdateSessionResponseWrapper responseWrapper =
|
||||||
new OnRedirectUpdateSessionResponseWrapper( (HttpServletResponse)response, request,
|
new OnRedirectUpdateSessionResponseWrapper( response, request,
|
||||||
httpSessionExistedAtStartOfRequest, contextHashBeforeChainExecution );
|
httpSessionExistedAtStartOfRequest, contextHashBeforeChainExecution );
|
||||||
|
|
||||||
// Proceed with chain
|
// Proceed with chain
|
||||||
|
@ -348,13 +355,13 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void storeSecurityContextInSession(SecurityContext securityContext,
|
private void storeSecurityContextInSession(SecurityContext securityContext,
|
||||||
ServletRequest request,
|
HttpServletRequest request,
|
||||||
boolean httpSessionExistedAtStartOfRequest,
|
boolean httpSessionExistedAtStartOfRequest,
|
||||||
int contextHashBeforeChainExecution) {
|
int contextHashBeforeChainExecution) {
|
||||||
HttpSession httpSession = null;
|
HttpSession httpSession = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpSession = ((HttpServletRequest) request).getSession(false);
|
httpSession = request.getSession(false);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ignored) {
|
catch (IllegalStateException ignored) {
|
||||||
}
|
}
|
||||||
|
@ -381,7 +388,7 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
httpSession = ((HttpServletRequest) request).getSession(true);
|
httpSession = request.getSession(true);
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ignored) {
|
catch (IllegalStateException ignored) {
|
||||||
}
|
}
|
||||||
|
@ -468,7 +475,7 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
*/
|
*/
|
||||||
private class OnRedirectUpdateSessionResponseWrapper extends HttpServletResponseWrapper {
|
private class OnRedirectUpdateSessionResponseWrapper extends HttpServletResponseWrapper {
|
||||||
|
|
||||||
ServletRequest request;
|
HttpServletRequest request;
|
||||||
boolean httpSessionExistedAtStartOfRequest;
|
boolean httpSessionExistedAtStartOfRequest;
|
||||||
int contextHashBeforeChainExecution;
|
int contextHashBeforeChainExecution;
|
||||||
|
|
||||||
|
@ -482,7 +489,7 @@ public class HttpSessionContextIntegrationFilter implements InitializingBean, Fi
|
||||||
* @see HttpSessionContextIntegrationFilter#storeSecurityContextInSession(SecurityContext, ServletRequest, boolean, int)
|
* @see HttpSessionContextIntegrationFilter#storeSecurityContextInSession(SecurityContext, ServletRequest, boolean, int)
|
||||||
*/
|
*/
|
||||||
public OnRedirectUpdateSessionResponseWrapper(HttpServletResponse response,
|
public OnRedirectUpdateSessionResponseWrapper(HttpServletResponse response,
|
||||||
ServletRequest request,
|
HttpServletRequest request,
|
||||||
boolean httpSessionExistedAtStartOfRequest,
|
boolean httpSessionExistedAtStartOfRequest,
|
||||||
int contextHashBeforeChainExecution) {
|
int contextHashBeforeChainExecution) {
|
||||||
super(response);
|
super(response);
|
||||||
|
|
Loading…
Reference in New Issue