Looks like you can't. Anything you need from the session / security has to be put on to the message itself, probably in the headers.
Spring JMS - getting SecurityContext from Message Driven Pojo (MDP)
-
04-07-2022 - |
Question
The 'standard' way (AFAIK) to get a Spring Security Context to, say, determine the current logged in user is:
User user = (User) SecurityContextHolder.getContext()
.getAuthentication().getPrincipal();
However if I run this same code in a JMS Message Driven Pojo (MDP), the context is null.
This make sense because a JMS event doesn't necessarily happen within a session, which is where the security context would live.
But since that's the case, is there a (standard) way for the security to be propagated through to the MDP, or, a way for it to be injected into the MDP?
Thanks, Roy
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow