Jersey and exception handling filtering

I have a jersey application configured with Spring Security Authentication. The jersey-spring package provides the SpringServlet class, which is registered in my web.xml as a servlet.

Authentication and everything works as expected. I am wondering how to get authentication exceptions (and other filter exceptions) sent through the Jersey servlet, so I can use our ExceptionMapper to handle them.

Originally, SpringServlet was configured as a filter, but after some reading, I realized that the servlet should be able to handle the Exceptions created in the filters (maybe this is a misunderstanding). I do not notice any changes in behavior after changing it to the servlet, and if I go through Spring security code, I can see where the HttpServletResponse is written.

My question is: is it possible for Jersey servlet process exceptions to be thrown using the Spring Security Filter?

+5
source share
1 answer

How you do this depends on whether you are referencing Jersey from Spring Security or Spring Security from Jersey.

Spring "" "", , .

, Spring, , , ( ). "" :

  • AuthenticationException AuthenticationFailureHandler.onAuthenticationFailure() ( ) , , FilterChain.doFilter()
  • AuthenticationFailureHandler, , ( ) , Spring, HttpServletRequest.getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION)

"" -, , .

0

All Articles