3 Replies Latest reply on Jan 8, 2007 5:36 PM by Alan Feng

    How to specify the username and password when connecting to

    Alan Feng Novice

      I searched this forum but didn't find any example so here is my problem:

      I've got the JBoss Messaging installed/converted all okay, test QueueExample worked fine with no user security checking. I've modified the properties file used by the messaging security domain and added additional users / roles. Now, the question is, how do I specify the username and password from the client program?

      I tried adding the following to the QueueExample:

       java.util.Hashtable env = new java.util.Hashtable();
       env.put(Context.SECURITY_PRINCIPAL, "user");
       env.put(Context.SECURITY_CREDENTIALS, "pass4user");
       env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
      
       ic = new InitialContext();
      

      And that generates error:
      javax.jms.JMSSecurityException: User: null is not authorized to write to destination testQueue

      The messaging-users.properties file:
      admin=pass4admin
      user=pass4user
      guest=guest
      


      The messaging-roles.properties file:
      admin=admin
      user=user
      guest=guest
      


      And the messaging-service.xml file:
       <attribute name="SecurityDomain">java:/jaas/messaging</attribute>
       <attribute name="DefaultSecurityConfig">
       <security>
       <role name="admin" read="true" write="true" create="true"/>
       <role name="user" read="true" write="true" create="true"/>
       </security>
       </attribute>
      


      As you can see, I removed the "guest" role from the the message-service.xml security settings. If I put the guest back, it worked just fine.

      So any idea what I am doing wrong?

      Thanks in advance.