Adding some custom code that is supposed to be launched while user logs in it isn’t available out of the box but it can be done easily. In order to do this you have to implement interface org.springframework.context.ApplicationListener.
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof AuthenticationSuccessEvent) {
AuthenticationSuccessEvent authEvent = (AuthenticationSuccessEvent) event;
String username = authEvent.getAuthentication().getName();
// Any custom logic
}
}
Such listener has to be registered. In order to do this – just create a bean in xml configuration file where other Acegi related beans are declared (usually security.xml or applicationContext-security.xml).
<bean class="my.package.SomeExampleListener">
<property name="someExampleManager" ref="someExampleManager"></property>
</bean>
You can inject any required dependencies here.
That’s all!