Spring Security: Authentication returns null -
I have configured a spring bean so that the security content can be returned:
& Lt; Bean id = "security context" class = "org.springframework.security.context.SecurityContextHolder" factory-method = "getContext" & gt; & Lt; / Bean & gt;
When I use this bean, the authentication object taps.
Authentication Authentication = SecurityContax. Getitization (); Valid authority [] Authorities = Authentication Constituted authority ();
The second line above causes a NPE. That sounds strange to me, because the following code returns to the authorities as expected:
valid authority [] officers = SecurityContextHolder.getContext (). GetAuthentication (). GetAuthorification ();
Actually I am trying to eliminate the static call to SecurityContextHolder.getContext () to make my code more qualified.
Any ideas on how this remedy is? Why are not security contractors given by Spring back to be able to return, while I can make a steady call from within my own code?
FYI I am executing code from within Stropes 2 Action.
SecurityContextHolder.getContext () Returns the context related to the current thread. Been Immediately the reference stored in your bean differs from the context of your application requirement. I do not think it is possible to store in context bean and use it all the time.
Comments
Post a Comment