activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "" <yunbinw...@travelsky.com>
Subject How to use java.naming.security.* for connecting Activemq?
Date Wed, 21 May 2014 03:17:53 GMT
Now ,I want to use java.naming.security.principal and java.naming.security.credentials to connection
Activemq, but it fails, I don't know why .

this is my code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
properties.load(new FileInputStream(new File("./jndi.properties")));

InitialContext jndiContext = new InitialContext(properties);

if (connectionFactory == null
|| connectionFactory.trim().length() == 0)
throw new IllegalArgumentException(
"Connection factory has not been provided");

ConnectionFactory factory = (ConnectionFactory) jndiContext
.lookup(connectionFactory);

Connection connection = factory.createConnection();
connection.start();

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this is file jndi.properties content:
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url=tcp://172.30.13.18:61616
java.naming.security.principal=test
java.naming.security.credentials=test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this is provider config
<plugins>
          <!-- Configure authentication; Username, passwords and groups -->
          <simpleAuthenticationPlugin>
              <users>
                  <authenticationUser username="test" password="test"
                   groups="users,admins"/>
             </users>
         </simpleAuthenticationPlugin>
        </plugins>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

my program can not connection MQ, it throw a exception like this, it seems username doesn't
pass to MQ , Did I miss something?


javax.jms.JMSException: User name [null] or password is invalid.
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:49)
at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1391)
at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1496)
at org.apache.activemq.ActiveMQConnection.start(ActiveMQConnection.java:524)
at com.datafeed.security.MQSecurityTest.main(MQSecurityTest.java:58)
Caused by: java.lang.SecurityException: User name [null] or password is invalid.
at org.apache.activemq.security.SimpleAuthenticationBroker.addConnection(SimpleAuthenticationBroker.java:77)
at org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:91)
at org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:766)
at org.apache.activemq.broker.jmx.ManagedTransportConnection.processAddConnection(ManagedTransportConnection.java:79)
at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139)
at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:329)
at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:184)
at org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50)
at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:288)
at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:214)
at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
at java.lang.Thread.run(Thread.java:722)
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message