ActiveMQ(5.10.0) - Configuring the jaas authentication plug-in

  JAAS provides pluggable authentication, which means ActiveMQ will use the same authentication API regardless of the technique used to verify user credentials (a text file, a relational database, LDAP, and so on). All that’s required is an implementation
of the javax.security.auth.spi.LoginModule interface and a configuration change to ActiveMQ. Fortunately, ActiveMQ comes with implementations of some modules that can authenticate users using properties files, LDAP, and SSL certificates, which will be enough for many use cases. Because JAAS login modules follow a specification, one advantage of them is that they’re relatively straightforward to configure. The best way to understand a login module is by walking through a configuration. For this task, the login module that works with properties files will be used.

  The first step in this task is to identify the PropertiesLoginModule so that ActiveMQ is made aware of it. To do so, you must create a file named login.config that contains a standardized format for configuring JAAS users and groups. Here are the contents of the file:

activemq-domain {
    org.apache.activemq.jaas.PropertiesLoginModule required
        org.apache.activemq.jaas.properties.user="users.properties"
        org.apache.activemq.jaas.properties.group="groups.properties";
};

  The login.config file shown here contains a few different items for configuring a JAAS module. The activemq-domain is the predominant item in this file and it contains all the configuration for the login module. First is the fully qualified name of the PropertiesLoginModule and the trailing notation identifying it as required. This means that the authentication can’t continue without this login module. Second is a line to enable debug logging for the login module; this is optional. Third is the org.apache.activemq.jaas.properties.user property, which points to the users.properties file. Fourth is the org.apache.activemq.jaas.properties.group property, which points to the groups.properties file. Once this is all defined, the two properties files must be created.

  NOTE: The PropertiesLoginModule used in this section is an implementation of a JAAS login module, and it comes with ActiveMQ.

  Defining user credentials in the properties files is simple. The users.properties file defines each user in a line-delimited manner along with its password, as shown:

admin=admin
producer=producer
consumer=consumer
guest=guest

  The groups.properties file defines group names in a line-delimited manner as well. But each group contains a comma-separated list of its users as shown:

admins=admin
producers=admin,producer
consumers=admin,producer,consumer
guests=guest

  Once these files are created, the JAAS plug-in must be defined in the ActiveMQ XML configuration file. The following is an example of this necessary change:

...
<plugins>
    <jaasAuthenticationPlugin configuration="activemq-domain" />
</plugins>
...

  The example is shortened for readability and only shows the necessary change to enable the JAAS login module. As you can see, the JAAS plug-in only needs the name of the JAAS domain in the login.config file. ActiveMQ will locate the login.config file on the classpath (an alternative to this is to use the java.security.auth.login.config system property for the location of the login.config file). To test out the JAAS login module that was just created, start up ActiveMQ using these changes. Here’s the command to use:

${ACTIVEMQ_HOME}/bin/activemq start -Djava.security.auth.login.config=/home/ucm/activemq/apache-activemq-5.10.2/conf/login.config

You can also set the environment variable:

export ACTIVEMQ_OPTS=-Djava.security.auth.login.config=/home/ucm/activemq/apache-activemq-5.10.2/conf/login.config

  The JAAS plug-in provides exactly the same functionality as the simple authentication plug-in. But it does so using the standardized Java mechanism, meaning you can use it to plug in any existing security policies you use inside your organization.

时间: 2024-12-24 00:39:18

ActiveMQ(5.10.0) - Configuring the jaas authentication plug-in的相关文章

ActiveMQ(5.10.0) - Configuring the simple authentication plug-in

The easiest way 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 l

ActiveMQ(5.10.0) - Destination-level authorization

To build upon authentication, consider a use case requiring more fine-grained control over clients to authorize certain tasks. ActiveMQ provides two levels of authorization: operation-level authorization and message-level authorization. These two typ

ActiveMQ(5.10.0) - Connection Configuration URI

An Apache ActiveMQ connection can be configured by explicitly setting properties on the ActiveMQConnection or ActiveMQConnectionFactory objects themselves via the bean properties or using the following URI syntax. Example You set the property called

ActiveMQ(5.10.0) - Message Redelivery and DLQ Handling

When messages expire on the ActiveMQ broker (they exceed their time-to-live, if set) or can’t be redelivered, they’re moved to a dead-letter queue, so they can be consumed or browsed by an administrator at a later point. Messages are redelivered to a

ActiveMQ(5.10.0) - 使用 JDBC 持久化消息

1. 编辑 ACTIVEMQ_HOME/conf/activemq.xml. <beans> <broker brokerName="localhost" persistent="true" xmlns="http://activemq.apache.org/schema/core"> <persistenceAdapter> <jdbcPersistenceAdapter dataSource=&quo

ActiveMQ(5.10.0) - hello world

Sending a JMS message public class MyMessageProducer { ... // 创建连接工厂实例 ConnectionFactory connFactory = new ActiveMQConnectionFactory( ActiveMQConnection.DEFAULT_USER, ActiveMQConnection.DEFAULT_PASSWORD, "tcp://localhost:61616"); Connection conn

GreenPlum 5.10.0 集群部署

第1部分 初始化系统配置 1.1 部署环境 序号 ip地址 主机名 内存 系统版本 内核版本 1 192.168.61.61 gpmaster61 16Gb CentOS 7.5.1804 3.10.0-862.9.1.el7.x86_64 2 192.168.61.62 gpsegment62 16Gb CentOS 7.5.1804 3.10.0-862.9.1.el7.x86_64 3 192.168.61.63 gpsegment63 16Gb CentOS 7.5.1804 3.10.

Using JAAS Authentication in Java Clients---weblogic document

The following topics are covered in this section: JAAS and WebLogic Server JAAS Authentication Development Environment Writing a Client Application Using JAAS Authentication Using JNDI Authentication Java Client JAAS Authentication Code Examples The

错误: 找不到或无法加载主类 Files\apache-activemq-5.10.0\bin\..\conf\login.config

在启动activemq的时候出现错误:“错误: 找不到或无法加载主类 Files\apache-activemq-5.10.0\bin\..\conf\login.config”,之前用activemq的时候没遇到这个问题,这次折腾就遇到了.每一次问题,都是一次收获和成长的机会,哪怕是一点点,没关系,不积跬步无以至千里! 查找login.config,明明路径E:\Program Files\apache-activemq-5.10.0\conf\login.config文件存在. 于是仔细阅读