securityContext.getAuthentication() is null in a Thread
Hi there,
In our webapp, we have something like this
SomeServiceClass {
private Executor taskExecutor; // gets set in a private method for now, but will be injected by spring xml later on.
doSomething() {
taskExecutor.execute( new Runnable() {
public void run() {
doNotify(some_final_string);
}
});
}
doNotify(final String xyz) {
SecurityContext securityContext = SecurityContextHolder.getContext();
// this always returns null in asynch mode but works in non-asynch mode.
securityContext.getAuthentication() ;
}
}
any idea why securityContext.getAuthentication() always returns null?
2nd question.
we've a PortalLogoutHandler class that implements Spring LogoutHandler
in public void logout( HttpServletRequest request, HttpServletResponse response, Authentication authentication ), we need to do something with authentication, but it's null by the time logout is called. Is there a preLogout() we can use ? another way to ask the question, if we need to do something with the authentication object prior to its being nullified, how can we achieve that?
thanks
securityContext.getAuthentication() is null in a Thread
Got it. I will try that. Thanks!