Introduction
By default, ActiveMQ does not provide access to the message broker anonymously. That means we don't need to pass user name and password. This is not desired. There are two simple authentication schemes. The firsts use simple authentication and the second one uses JAAS plugin. JASS plugin can be used with LDAP.
In this blog, I am going explain how to use jaasAuthenticationPlugin.
Configuration Changes
To configure ActiveMQ using JAAS authentication plugin requires to modify the following files [all these files are located at $ACTIVEMQ_HOME/conf:
- login.config
- users.properties
- groups.properties
- activemq.xml
activema.xml
... ...
login.config
activemq-domain { org.apache.activemq.jaas.PropertiesLoginModule required debug=true org.apache.activemq.jaas.properties.user="users.properties" org.apache.activemq.jaas.properties.group="groups.properties"; };Note: configuration="activemq-domain" in the activemq.xml implies that ActiveMQ will look for the entry of activemq-domain in the login.config file.
users.properties
admin=admin hmuser=user123@
groups.properties
admins=admin users=hmuser
Test Configuration
To test the configuration, you can run the following scripts:
producer: runProducerOneWay.sh
#!/bin/bash ACTIVEMQ_HOME=/opt/app/amq/Transport/NioSsl ant producer \ -Durl="nio+ssl://localhost:61617" \ -Duser="hmuser" \ -Dpassword="user123@" \ -Dtopic=false \ -Ddurable=true \ -Dsubject=QUEUE.NIOSSL \ -Dmax=100 \ -Djavax.net.debug=ssl:handshake \ -Djavax.net.ssl.keyStore=/home/amq/client.ks \ -Djavax.net.ssl.keyStorePassword=amqadmin@ \ -Djavax.net.ssl.trustStore=/home/amq/client.ts
consumer: runConsumerOneWay.sh
#!/bin/bash ACTIVEMQ_HOME=/opt/app/amq/Transport/NioSsl ant consumer \ -Durl="nio+ssl://localhost:61617" \ -Duser="hmuser" \ -Dpassword="user123@" \ -Dtopic=false \ -Ddurable=true \ -Dsubject=QUEUE.NIOSSL \ -Djavax.net.ssl.keyStore=${ACTIVEMQ_HOME}/conf/client.ks \ -Djavax.net.ssl.keyStorePassword=amqadmin@ \ -Djavax.net.ssl.trustStore=${ACTIVEMQ_HOME}/conf/client.ts
Hey there Sir Liu,
ReplyDeleteCould you please explain me how to add my own Jaas Plugin?
I did a lot of the things other sides explained, but nothing really worked.
Best Wishes
Bibadchoia