I have a Spring-MVC application (i.e. I am using a Spring dispatcher servlet). I also use Spring Security to authenticate users. Since I am using the Spring dispatcher servlet, I should NOT declare
<listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener>
in my web.xml to be able to use RequestContextHolder
(if I understand the documentation correctly).
My question relates to my implementation of the org.springframework.security.web.authentication.AuthenticationSuccessHandler
interface:
public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler { @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException { int timeout = 60*60;
Could you explain why in the above code, RequestContextHolder.currentRequestAttributes()
and HttpServletRequest.getUserPrincipal()
do not work (they work inside the controller)?
Thanks!
source share