Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <security:authentication-manager>
- <security:authentication-provider>
- <security:jdbc-user-service data-source-ref="dataSource"
- users-by-username-query="select username, password, name, enabled, name from users where username=?"
- authorities-by-username-query="select us.username, ur.authority from users us, userroles ur
- where us.user_id = ur.user_id and us.username =? "
- />
- </security:authentication-provider>
- </security:authentication-manager>
- @Component
- public class AuthenticationEventListener implements ApplicationListener<AbstractAuthenticationEvent> {
- // private static Logger logger = Logger.getLogger(AuthenticationEventListener.class);
- @Override
- public void onApplicationEvent(AbstractAuthenticationEvent authenticationEvent) {
- if (authenticationEvent instanceof InteractiveAuthenticationSuccessEvent) {
- // ignores to prevent duplicate logging with AuthenticationSuccessEvent
- return;
- }
- Authentication authentication = authenticationEvent.getAuthentication();
- String auditMessage = "Login attempt with username: " + authentication.getName() + "ttSuccess: " + authentication.isAuthenticated();
- System.out.println(auditMessage);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement