The easiest-to-secure the broker is through the use of authentication credentials placed directly in the broker ' s XML Configuration file. Such functionality is provided by the simple authentication plug-in that's part of ActiveMQ. The following listing provides an example of using this plug-in.
<Plugins> <Simpleauthenticationplugin> <Users> <Authenticationuserusername= "Admin"Password= "Admin"groups= "Admins,publishers,consumers"/> <Authenticationuserusername= "publisher"Password= "publisher"groups= "Publishers,consumers"/> <Authenticationuserusername= "Consumer"Password= "Consumer"groups= "Consumers"/> <Authenticationuserusername= "Guest"Password= "Guest"groups= "Guests"/> </Users> </Simpleauthenticationplugin></Plugins>
By using this-simple configuration snippet, the four users can now access ActiveMQ. Obviously, for authentication purposes, each user must has a username and a password. Additionally, the groups attribute provides a comma-separated list of groups to which the user belongs. This information was used for authorization purposes, as would be seen shortly.
The preceding exception is expected because a security plug-in are activated but the authentication credentials haven ' t yet been defined in the Publisher client. To fix this exception, modify the Publisher to add a username and password. The following snippet provides an example of this:
private String username = "Publisher ; private String Password = "publisher" ; public Publisher () throws JMSException {Factory = new Activemqconnectionfactory ( Brokerurl); Connection = factory.createconnection (username, password); Connection.start (); Session = Connection.createsession (false = Session.createproducer (null );}
As the preceding snippet shows, the only necessary change was to define a username and a password that's then used as par Ameters to the CreateConnection () method.
Unfortunately, with the simple authentication plug-in, passwords is stored (and transferred) as clear text, which impacts The security of the broker. But even plain-text passwords prevent unauthorized clients from interacting with the broker, and in some
Environments this was all that's needed. Additionally, you can consider using the simple authentication plug-in in combination with the SSL transport, which would a t least solve the problem of sending plain passwords over the network.
ActiveMQ (5.10.0)-Configuring the Simple Authentication Plug-in