Announcement Announcement Module
Collapse
No announcement yet.
Intercept login and logout Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Intercept login and logout

    Hi,

    I just started on a project that's using Spring Security and I would like to intercept successful login and logout to do some actions at those point of times.
    Any idea what's the best way to achieve that is?

    Thanks

  • #2
    Any indication as to where I need to put my plumbing code to run the logic required during those events (success login, logout) would pretty much be all I need.

    Comment


    • #3
      Lance, what about that table on page 12 (of the pdf)? There's documentation there for inserting more filters.

      Comment


      • #4
        You can also use the events that Spring Security generates if that is sufficient (write an ApplicationEventListener).

        Comment


        • #5
          Ok so I figured out the login interception business using a SecurityListener class implementing a ApplicationListener and checking the type of the ApplicationEvent passed in like this:

          Code:
          public void onApplicationEvent(ApplicationEvent event) 
          {
              if (event instanceof AuthenticationSuccessEvent) 
              {
                  ...
              }
          }
          Now my next problem is that there I can't seem to find a class representing a logout event. At this point I'm starting to wonder if logging out triggers an application event that would go through my securitylistener at all?

          Any idea?

          Comment


          • #6
            I just wanted to follow up on this, did anyone find a way to run some code when a user logs out? Explicitly and implicitly (session times out)? I need to do some processing on these events as well, and would like access to the UserDetails object to facilitate it.

            Thanks,
            David
            Last edited by halcyon; Feb 10th, 2009, 02:29 AM.

            Comment


            • #7
              I have the same question: how to trigger code on logout.
              This thread http://forum.springframework.org/showthread.php?t=29115
              offers a suggestion, it that the excepted practice?
              Or has this event been incorporated into the framework in 2 years?

              Comment

              Working...
              X