Announcement Announcement Module
Collapse
No announcement yet.
How do I get at my UserDetails object from my controllers? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I get at my UserDetails object from my controllers?

    Once Acegi has grabbed my custom UserDetails object from the database and validated it, how can I get at it again from later in my processing, i.e. a SimpleFormController. I've been looking around for the good part of the night and found that I can get to it from ContextHolder... but how do I get to ContextHolder? Thanks!

  • #2
    I just using the following code to get my UserDetails Object again:
    Code:
    SecureContext sc = (SecureContext) (ContextHolder.getContext());
    (SecurityUser) sc.getAuthentication().getPrincipal();

    Comment


    • #3
      Yea, but where are you getting ContextHolder from?

      Comment


      • #4
        try
        import net.sf.acegisecurity.context.*;

        And may the Acegi "magic" be with you! :wink:

        Cheers,
        Gustavo

        Comment


        • #5
          Oh, it's a static method. hehe, I wasn't expecting it to be that simple. Sorry.

          EDIT: And as far as I'm concerned, a static method that returns a thread-specific object IS majic.

          Comment

          Working...
          X