Interceptors of Spring 5.0 can still be used to implement audit trails, transaction monitoring, session tracking, and additional request functionalities. These components filter and evaluate all incoming requests before they reach the @Controller
. This recipe will show how interceptors can be a great help for the authentication process and session management.
This last recipe is an add-on to the Spring Security framework. Although interceptors are Spring MVC components, these support classes can help manage some parts of the security chain. This recipe will utilize ch04
and will update some of our context definition classes.
To apply an interceptor that will monitor and evaluate the /login.html
request:
- Let us create a class of
HandlerInterceptor
type that keeps track of the access time of each user:
public class LoginInterceptor implements HandlerInterceptor{ @Override public void afterCompletion(HttpServletRequest...