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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top