Results 1 to 9 of 9

Thread: Session validation

Hybrid View

  1. #1
    Join Date
    Nov 2010
    Location
    malaysia
    Posts
    12

    Default Session validation

    Hello all,

    I have a question on what is the best way to validate user session?
    i know the code how to check it already, but currently i have to copy the method to all of the page's controller.

    Is there any better way to solve it? so i just create a function then every page automatically will be validated by that function without calling the function (put the function in the controller) ? or using something like interceptor (if yes please tell me how to use it)?


    Thank you guys.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    Can you describe what you mean by validate session? Are you trying to validate that a user exists and has permission to access the page? If so, Spring Security will do that in its core filters which is outside of the controller.
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

  3. #3
    Join Date
    Nov 2010
    Location
    malaysia
    Posts
    12

    Default

    Yes something like that, actually its only simple thing. for example is the session expired? or is the session exist?
    Currently im using database to validate, thats why i need a function that is created by me to validate. Is it possible if i use interceptor? if so could you tell me how to use it?


    Thanks

  4. #4
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    I'm not sure I understand. Usually the session existing/expiration is managed by the Container (i.e. Tomcat). If that session is expired or does not exist then Spring Security will not have an authenticated Authentication in the SecurityContextHolder. This means you should not have to inspect a database to determine if the session exists/is expired under most circumstances. Do you have custom session management needs?
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

  5. #5
    Join Date
    Nov 2010
    Location
    malaysia
    Posts
    12

    Default

    Yes, i have a custom session management. so i need to use my own code.
    Thanks

  6. #6
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    I'm still not sure I understand what you want to do. If you want to do something on every request, you can create a Filter and validate the session in it.
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

Posting Permissions

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