java - how to obtain JSF app username from stateless session bean -
In our app, we get JSF & amp; Amp; EJB 3.0 (Eclipse Link 2.0) We need to use the Oracle Proxy authorization for each connection in our Stateless Session Beans. For this, we have to get the DB username to connect with the Threat Proxy.
There is an article on the topic
So when a certified user calls a JSF managed bean method in which it calls a few sessions, the Bean method can be used in some way by using its username Should be passed for.
I do not have very good solutions right now: - Pass the username as a parameter in every session method (not very clean but will work); - Solution of the above article: To use the class member variable of Session Bean to store the Usage (thread is safe and potentially not dangerous)
PS I have found a solution which thread is using local variables: _http: //www.adam-bien.com/roller/abien/entry/how_to_pass_context_withIt works fine, but still there is a problem that I have given to each JSF session Before the Bean, each e-SB session needs to be inserted before the bean, because it should be in the same thread.
If your users are certified by the container, then you javax.ejb.SessionContext ejb, you can use the username:
@Resource Private session context reference; Private string getCurrentUsername () {return context.getCallerPrincipal (). GetName (); } Edit: This works if authentication is configured in web.xml by login-configuration and security-blocking elements. If you are certifying yourself, then you can use a service filter and an HTTPSVERTUZ application which overrides user principal, remote user and user inorol (tested in glassfish). If you want to handle authentication in JSF bean, this will probably not work, because it will be already initialized and injected. You can still create a session scoped ejb which just puts the username and puts this bean in your stateless beans.
Comments
Post a Comment