Implementing user authentication
Although Spring Security is the most straightforward and easy solution for securing any Spring MVC applications, software designers always need the option of customizing the authentication procedure for non-complex and small-scale security requirements. This recipe will provide the solution for how to use @Aspect
and advices in implementing security modules.
Getting started
Open ch05
and add the following @Aspect
to the loginSubmit()
request handler of EmployeeController
.
How to do it...
Let us create a custom login interceptor that validates the user's credentials using database authentication:
- This recipe uses aspects to pre- and post-validate user credentials using the authentication services provided by the previous recipes. Create an aspect class,
LoginAuthAspect
, which contains the following@Pointcut
definitions and aLog4J
logger:
@Component @Aspect public class LoginAuthAspect { private Logger logger = Logger.getLogger(LoginAuthAspect.class...