There are some session mechanisms in EJB, but they all start at the beginning of the remote call and end when it ends. The old one shows the context of the transaction (Adam Bien wrote about this some time ago), and the newer one in the field of CDI sessions.
Contrary to popular belief, this area not only reflects the area of ββthe http session, but in the absence of an http session (for example, for remote calls) it represents a single call chain or message delivery (for mdbs).
With such a session, your remote SWT client should still pass sessionId to the remote service, but any local beans called from there can select it from this cdi session.
Another option is similar to what jtahlborn says: with your own login module, you can return the user principle, not the default. Your code may first request a normal principal, and then try to execute it.
The problem is that this material is container specific, and JBoss always forgets about it. This breaks down badly after each update, and users are forced to kick and scream in order to fix it in the next version (only to see how after that it will break again in the version). Without JBoss really supporting this, this is an endless battle.
Another option is to let the user log in as sessionId. The input module behind it can be a simple module that accepts everything and simply puts the principal in the security context with sessionId as the "name". This is a bit strange, but we have successfully used this to get any data that can be expressed as a string in a security context. Of course, you will need to allow your client to perform basic container authentication, which in turn wins using Spring security.
source share