ActiveMQ authentication is divided into two kinds of simple authentication and JAAS authentication, both of which are implemented through plug-ins. When creating a link, you need to specify a user name and password, factory.createConnection("publisher","password");
Simple authentication configuration :
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="admin" password="password" groups="admins,publishers,consumers" />
<authenticationUser username="publisher" password="password" groups="publishers,consumers" />
<authenticationUser username="consumer" password="password" groups="consumers" />
<authenticationUser username="guest" password="password" groups="guests" />
</users>
</simpleAuthenticationPlugin>
</plugins>
JAAS authentication configuration :
<plugins>
<jaasAuthenticationPlugin configuration="activemq-domain" />
</plugins>
Configuration values are defined in the login.config file, activemq loads the login.config file through the classpath or through the java.security.auth.login.config parameter
The content of login.config is:
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";
};
The PropertiesLoginModule implements the javax.security.auth.spi.LoginModule interface
users.properties file content :
admin=password
publisher=password
consumer=password
guest=password
groups.properties file content:
admins=admin
publishers=admin,publisher,sslpublisher
consumers=admin,publisher,consumer,sslconsumer
guests=guest