[jboss-user] [JBoss Messaging] - Transparent login to JBoss Messaging
chand0s
do-not-reply at jboss.com
Tue Nov 27 03:31:01 EST 2007
env: JBoss 4.2.2 + JBoss Messaging 1.4
problem: I have my own LoginModule. All beans and destinations are configured to use it. I have, for example, user with name "user", password "password" and role "role".
When I need to invoke bean's method, I pass username/password through JNDI (SECURITY_PRINCIPAL/SECURITY_CREDENTIALS).
When I need to work with some queue, I do login procedure look like this:
| InitialContext ctx = new InitialContext(<don't pass user/pwd here>);
| ConnectionFactory cf = (ConnectionFactory) ctx.lookup("/ConnectionFactory");
| Connection = cf.createConnection("user", "password"); // pass user/password here
| ..........................
|
I do it from client and all works fine. But how I can work with JMS from bean? Now I make it like:
| @RolesAllowed(value="role")
| public void someBeanMethod() {
| String currentUser = sessionContext.getPrincipal().getName(); // username, who invoked this bean's method
| String password = getPasswordFromDatabase(currentUser); // get password from db
| InitialContext ctx = new InitialContext();
| ConnectionFactory cf = (ConnectionFactory) ctx.lookup("/ConnectionFactory");
| Connection = cf.createConnection(currentUser, password); // I don't want to do it!
| ..............
| }
I don't want to do second login actions, because I have done one login when I invoked bean's method. How I can work with JBoss Messaging from bean's method with username/password, who invoked bean's method.
P.S. Sorry for my english, I'm not native speaker.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107953#4107953
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107953
More information about the jboss-user
mailing list