【发布时间】:2017-11-26 16:09:20
【问题描述】:
我必须多次阅读 HttpServletRequest。我已经像那些帖子Http Servlet request lose params from POST body after read it once中所说的那样包装了HttpServletRequest@
在我扩展 AbstractAuthenticationProcessingFilter 的过滤器类中,我可以在successfulAuthentication 方法中使用和链接请求,因为它具有链参数。但除了这些解决方案之外,我还必须在尝试和成功的身份验证步骤之间链接请求:
public Authentication attemptAuthentication(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws AuthenticationException, IOException, ServletException {
// wrapping request and consuming
}
@Override
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException {
// Since i couldn't chain wrapped httpServletRequest from attemptAuthentication step, this request still gets non-wrapping one and inputstream is empty
}
如何将包装的请求从尝试身份验证传递到成功身份验证?
【问题讨论】: