Skip to content

Instantly share code, notes, and snippets.

@dmarko484
Created January 11, 2017 14:10
Show Gist options
  • Save dmarko484/b3bd04485dcf32aa8dcab3d7e0051ff3 to your computer and use it in GitHub Desktop.
Save dmarko484/b3bd04485dcf32aa8dcab3d7e0051ff3 to your computer and use it in GitHub Desktop.
package app.config;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
@Component
public class LoginListener implements ApplicationListener<InteractiveAuthenticationSuccessEvent> {
@Override
public void onApplicationEvent(InteractiveAuthenticationSuccessEvent event)
{
UserDetails user = (UserDetails) event.getAuthentication().getPrincipal();
System.out.println("LOGIN name: "+user.getUsername());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment