Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <security:authentication-manager>
  2. <security:authentication-provider>
  3. <security:jdbc-user-service data-source-ref="dataSource"
  4. users-by-username-query="select username, password, name, enabled, name from users where username=?"
  5. authorities-by-username-query="select us.username, ur.authority from users us, userroles ur
  6. where us.user_id = ur.user_id and us.username =? "
  7. />
  8. </security:authentication-provider>
  9. </security:authentication-manager>
  10.  
  11. @Component
  12. public class AuthenticationEventListener implements ApplicationListener<AbstractAuthenticationEvent> {
  13. // private static Logger logger = Logger.getLogger(AuthenticationEventListener.class);
  14.  
  15. @Override
  16. public void onApplicationEvent(AbstractAuthenticationEvent authenticationEvent) {
  17. if (authenticationEvent instanceof InteractiveAuthenticationSuccessEvent) {
  18. // ignores to prevent duplicate logging with AuthenticationSuccessEvent
  19. return;
  20. }
  21. Authentication authentication = authenticationEvent.getAuthentication();
  22. String auditMessage = "Login attempt with username: " + authentication.getName() + "ttSuccess: " + authentication.isAuthenticated();
  23. System.out.println(auditMessage);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement