欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ActiveMQ用户认证

程序员文章站 2022-03-22 21:44:05
...

ActiveMQ认证分为两种简单认证与JAAS认证,都是通过插件方式实现,创建链接时需要指定用户名与密码,factory.createConnection("publisher","password");

简单认证配置

<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认证配置:

<plugins>

<jaasAuthenticationPlugin configuration="activemq-domain" />

</plugins>

Configuration值在login.config文件中定义,activemq通过classpath或者是通过java.security.auth.login.config参数加载login.config文件

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";

};

其中PropertiesLoginModule实现了javax.security.auth.spi.LoginModule接口

users.properties文件内容

admin=password

publisher=password

consumer=password

guest=password

 

groups.properties文件内容:

admins=admin

publishers=admin,publisher,sslpublisher

consumers=admin,publisher,consumer,sslconsumer

 guests=guest

 

相关标签: activemq 认证