Announcement Announcement Module
Collapse
No announcement yet.
Getting Session in AOP beforeAdvice methodI Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Session in AOP beforeAdvice methodI

    I need to develop a service which can authenticate user if he is already logged in before going to any other page. I am setting an attribute in session for this once the user is logged in.

    My question is, is there any way I can get Session object in beforeAdvice method of Spring AOP, so that I can access attribute for authentication.

    any reply much appreciated.
    -artofabhi

  • #2
    I would implement this with a ServletFilter, this way you have access to all the stuff in the request and session. Use the DelegatingFilterProxy so that you can configure your Filter as a normal Spring bean.

    If you really need to or want to implement it as an Aspect I would also suggest that you define a filter. That filter will put the desired parameter in a ThreadLocal, that way you can retrieve the proper value from inside the Aspect.

    Comment

    Working...
    X