Hi all,
Flat-file JMS authentication is easy to set up on Glassfish (see http://docs.sun.com/app/docs/doc/821-0027/aeofg?a=view).
The problem is the client part. I am writing a standalone Java client to access my JMS ressources (ConnectionFactory
and Destination
) via JNDI.
How to pass a username and a password to JMS from that client ?
I already tried several things such as:
1) Adding those credentials in the InitialContext
context.addToEnvironment(InitialContext.SECURITY_PRINCIPAL, "username");
context.addToEnvironment(InitialContext.SECURITY_CREDENTIALS, "password");
2) Using JMS username and password parameters in the connection factory
connectionFactory.createConnection();
However, none of those methods is working.
When I run the program, I just get:
com.sun.messaging.jms.JMSSecurityException: [C4084]: Échec de
l'authentification de l'utilisateur : user=guest, broker=localhost:7676(34576)
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.authenticate
(ProtocolHandler.java:1084)
So it keeps trying to authenticate with the "guest" user.
For this test, I used connection.NORMAL.deny.user=*
as permission rule (accesscontrol.properties
).
The interesting part is that this exception is thrown even before the connection factore is obtained:
InitialContext context = new InitialContext();
ConnectionFactory connectionFactory =
(ConnectionFactory)context.lookup("jms/middleware/factory");
/* The exception is thrown here, so authentication MUST have happened
before already (i.e. NOT in the createConnection(username, password) method) */
Hope someone knows the answer.
Many thanks in advance
Regards,
Dinesh