activemq分爲控制端和客戶端,下面分別介紹安全認證配置方法。apache
1.控制端安全配置安全
(1). ActiveMQ目錄conf下找到jetty.xml:eclipse
<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint"> <property name="name" value="BASIC" /> <property name="roles" value="user,admin" /> <!-- set authenticate=false to disable login --> <property name="authenticate" value="true" /> </bean>
含義:tcp
<property name="authenticate" value="true" /> true:須要認證; false:不須要認證ui
(2). ActiveMQ目錄conf下找到jetty-realm.propertiesspa
# username: password [,rolename ...]
admin: admin123, admin
user: user, user
說明:debug
第一個admin,爲認證用戶名。
第二個admin123,爲認證密碼。
第三個admin,爲角色。code
(3). 重啓ActiveMQ驗證是否須要認證
重啓activemq後,訪問:http://127.0.0.1:8161/admin/,彈出http基本認證框,這時候認證生效。xml
1.客戶端安全配置blog
(1). 解壓目錄/conf/activemq.xml的broken中添加:
<plugins> <!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS --> <jaasAuthenticationPlugin configuration="activemq" /> <!-- lets configure a destination based authorization mechanism --> <authorizationPlugin> <map> <authorizationMap> <authorizationEntries> <authorizationEntry topic=">" read="admins" write="admins" admin="admins" /> <authorizationEntry queue=">" read="admins" write="admins" admin="admins" /> <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/> <authorizationEntry queue="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/> </authorizationEntries> </authorizationMap> </map> </authorizationPlugin> </plugins>
如果集羣則broken中繼續添加:
<networkConnectors> <networkConnector userName="用戶名" password="密碼" uri="static:(tcp://localhost:61616)" duplex="true"/> </networkConnectors>
(2). 解壓目錄/conf/login.config中:
activemq{
org.apache.activemq.jaas.PropertiesLoginModule required
debug=true
org.apache.activemq.jaas.properties.user="users.properties"
org.apache.activemq.jaas.properties.group="groups.properties";
};
(3). 解壓目錄/conf/groups.properties中:
admins=用戶名
(4). 解壓目錄/conf/users.properties中:
用戶名=密碼