Concurrent access control can also be feasible in AOP since we can improvise the authentication process through the @Aspect
interception. If aspects can communicate with each other through session attributes, we can utilize the existing session of the application to count the number of user accesses per account.
Update LoginAuthAspect
in order to manage the number of allowable user access privileges an account can utilize.
Without using Spring Security, let us simulate concurrent user control by using AOP and following these steps:
- Create a
@Bean
ofMap
type that will hold all usernames that are currently logged in to the application. Inject thisMap
inSpringContextConfig
:
Configuration @EnableWebMvc @EnableAspectJAutoProxy @ComponentScan(basePackages="org.packt.aop.transaction") public class SpringContextConfig { @Bean public Map<String,Integer> authStore(){ return new HashMap<>(); } }
- Update...