Results 1 to 2 of 2

Thread: HttpServletRequest from AuthenticationSuccessEvent

  1. #1

    Default HttpServletRequest from AuthenticationSuccessEvent

    I have a LoggingListener bean that also accepts AuthenticationSuccessEvent's

    PHP Code:
        public void onApplicationEvent(ApplicationEvent appEvent) {
        if(
    appEvent instanceof AuthenticationSuccessEvent){
            
    AuthenticationSuccessEvent event = (AuthenticationSuccessEventappEvent;
            
    Authentication auth event.getAuthentication(); 
    is there a way i can reach the HttpServletRequest that resulted into this successfull authentication ? i d like to log the ip of the user.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    You can retrieve the details (auth.getDetails() ). You can set the implementation to use on the AuthenticationProcessingFilter. However the default already points to the WebAuthenticationDetails.

    Code:
    Authentication auth = event.getAuthentication();
    WebAuthenticationDetails details = auth.getDetails();
    String address = details.getRemoteAddress();
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •