my dog learned polymorphism
The moose likes Spring and the fly likes Updating SecurityContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Updating SecurityContext " Watch "Updating SecurityContext " New topic

Updating SecurityContext

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 549

I have a small question regarding the SecurityContext update.

I noticed that when I use the following lines the SecurityContext is not really (or never ???) updated :

However, if i use the following lines, the SecurityContext is systematically updated :

So, the line SecurityContextHolder.getContext().setAuthentication(auth); does correctly update the security context.

But aren't these two ways of doing the same thing ?
Why does the first method does not work ?

Thanks for enlightening me.

SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Rishi Shehrawat
Ranch Hand

Joined: Aug 11, 2010
Posts: 218

The SecurityContextHolder is able to reterieve the context from threadlocal, which is where it is kept/stored by Spring.
subject: Updating SecurityContext
jQuery in Action, 3rd edition