Results 1 to 2 of 2

Thread: Getting Session in AOP beforeAdvice methodI

  1. #1
    Join Date
    Mar 2007
    Posts
    8

    Lightbulb 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    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.
    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
  •