一侈贷, 控制臺(tái)安全配置
- ActiveMQ目錄conf下找到j(luò)etty.xml:
<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> <property name="authenticate" value="true" /> true:需要認(rèn)證; false:不需要認(rèn)證
2.ActiveMQ目錄conf下找到j(luò)etty-realm.properties:
# username: password [,rolename ...]
admin: admin123, admin
user: user, user
說(shuō)明:
第一個(gè)admin潭苞,為認(rèn)證用戶名庶诡。
第二個(gè)admin123唬血,為認(rèn)證密碼。
第三個(gè)admin绒窑,為角色棕孙。
3 重啟ActiveMQ驗(yàn)證是否需要認(rèn)證
重啟activemq后,訪問(wèn):http://127.0.0.1:8161/admin/,彈出http基本認(rèn)證框蟀俊,這時(shí)候認(rèn)證生效钦铺。
二 ,客戶端安全配置
解壓目錄/conf/activemq.xml的broker中添加:
<plugins>
普通認(rèn)證策略
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="test" password="test" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
<!--使用JAAS插件進(jìn)行高級(jí)認(rèn)證策略-->
<jaasAuthenticationPlugin configuration="activemq" />
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<!--authorizationEntry topic="FirstTopic" read="smeall,smeadmin" write="smeadmin" admin="smeall,smeadmin" /-->
<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>