Hi!
I want to keep a log of all successful (or not) authentications. I am using Spring Security 3.1.1 and Digest Authentication (org.springframework.security.web.authentication.www.DigestAuthenticationFilter and org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint). To catch authentication successful (or not) events I have written my own implementations:
andCode:public class AuthenticationSuccessfulEvent implements ApplicationListener<AuthenticationSuccessEvent> { @Autowired protected AccessHistoryService accessHistoryService; @Override public void onApplicationEvent(AuthenticationSuccessEvent event) { String username = event.getAuthentication().getName(); String userIp = ((WebAuthenticationDetails) event.getAuthentication().getDetails()).getRemoteAddress(); accessHistoryService.logSuccessfulAccess(username, userIp); } }
Both are registered in spring. And while the first one works as a charm the other does not. Do any of you have any clue why?Code:public class AuthenticationUnsuccessfulEvent implements ApplicationListener<AbstractAuthenticationFailureEvent> { @Autowired protected AccessHistoryService accessHistoryService; @Override public void onApplicationEvent(AbstractAuthenticationFailureEvent event) { String username = event.getAuthentication().getName(); String userIp = ((WebAuthenticationDetails) event.getAuthentication().getDetails()).getRemoteAddress(); accessHistoryService.logUnsuccessfulAccess(username, userIp); } }
Any help would be appreciated.
Best regards,
Bartosz


Reply With Quote
