ActiveMQ in Action(4) - Security
关键字: activemq
2.4 Security
ActiveMQ支持可插拔的安全机制,用以在不同的provider之间切换。
2.4.1 Simple Authentication Plugin
Simple Authentication Plugin适用于简单的认证需求,或者用于建立测试环境。它允许在XML配置文件中指定用户、用户组和密码等信息。以下是ActiveMQ配置的一个例子:
- <plugins>
- ...
- <simpleAuthenticationPlugin>
- <users>
- <authenticationUser username="system" password="manager" groups="users,admins"/>
- <authenticationUser username="user" password="password" groups="users"/>
- <authenticationUser username="guest" password="password" groups="guests"/>
- </users>
- </simpleAuthenticationPlugin>
- </plugins>
2.4.2 JAAS Authentication Plugin
JAAS Authentication Plugin依赖标准的JAAS机制来实现认证。通常情况下,你需要通过设置java.security.auth.login.config系统属性来配置login modules的配置文件。如果没有指定这个系统属性,那么JAAS Authentication Plugin会缺省使用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";
};
这个login.config文件中设置了两个属性:org.apache.activemq.jaas.properties.user和org.apache.activemq.jaas.properties.group分别用来指向user.properties和group.properties文件。需要注意的是,PropertiesLoginModule使用本地文件的查找方式,而且查找时采用的base directory是login.config文件所在的目录。因此这个login.config说明user.properties和group.properties文件存放在跟login.config文件相同的目录里。
以下是ActiveMQ配置的一个例子:
- <plugins>
- ...
- <jaasAuthenticationPlugin configuration="activemq-domain" />
- </plugins>
ActiveMQ JAAS还支持LDAPLoginModule、CertificateLoginModule、TextFileCertificateLoginModule等login module。
2.4.3 Custom Authentication Implementation
可以通过编码的方式为ActiveMQ增加认证功能。例如编写一个类继承自XBeanBrokerService。
- package com.yourpackage;
- import java.net.URI;
- import java.util.HashMap;
- import java.util.Map;
- import org.apache.activemq.broker.Broker;
- import org.apache.activemq.broker.BrokerFactory;
- import org.apache.activemq.broker.BrokerService;
- import org.apache.activemq.security.SimpleAuthenticationBroker;
- import org.apache.activemq.xbean.XBeanBrokerService;
- public class SimpleAuthBroker extends XBeanBrokerService {
- //
- private String user;
- private String password;
- @SuppressWarnings("unchecked")
- protected Broker addInterceptors(Broker broker) throws Exception {
- broker = super.addInterceptors(broker);
- Map passwords = new HashMap();
- passwords.put(getUser(), getPassword());
- broker = new SimpleAuthenticationBroker(broker, passwords, new HashMap());
- return broker;
- }
- public String getUser() {
- return user;
- }
- public void setUser(String user) {
- this.user = user;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- }
- <beans>
- …
- <auth:SimpleAuthBroker
- xmlns:auth="java://com.yourpackage"
- xmlns="http://activemq.org/config/1.0" brokerName="SimpleAuthBroker1" user="user" password="password" useJmx="true">
- <transportConnectors>
- <transportConnector uri="tcp://localhost:61616"/>
- </transportConnectors>
- </auth:SimpleAuthBroker>
- …
- </beans>
2.4.4 Authorization Plugin
可以通过Authorization Plugin为认证后的用户授权,以下ActiveMQ配置文件的一个例子:
- <plugins>
- <jaasAuthenticationPlugin configuration="activemq-domain"/>
- <authorizationPlugin>
- <map>
- <authorizationMap>
- <authorizationEntries>
- <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
- <authorizationEntry queue="USERS.>" read="users" write="users" admin="users" />
- <authorizationEntry queue="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
- <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
- <authorizationEntry topic="USERS.>" read="users" write="users" admin="users" />
- <authorizationEntry topic="GUEST.>" read="guests" write="guests,users" admin="guests,users" />
- <authorizationEntry topic="ActiveMQ.Advisory.>" read="guests,users" write="guests,users" admin="guests,users"/>
- </authorizationEntries>
- </authorizationMap>
- </map>
- </authorizationPlugin>
- </plugins>
ActiveMQ in Action(4) - Security的更多相关文章
- 《ActiveMQ in Action》【PDF】下载
内容介绍TheApache ActiveMQ message broker is an open source implementation ofthe Java Message Service sp ...
- ActiveMQ in Action(7) - Wildcards
关键字: activemq 2.6.7 Wildcards Wildcards用来支持联合的名字分层体系(federated name hierarchies).它不是JMS规范的一部分,而是A ...
- ActiveMQ in Action(6) - Features
关键字: activemq 2.6 Features ActiveMQ包含了很多功能强大的特性,下面简要介绍其中的几个.2.6.1 Exclusive Consumer Queue中的消息 ...
- ActiveMQ in Action(5) - Clustering
关键字: activemq 2.5 Clustering ActiveMQ从多种不同的方面提供了集群的支持.2.5.1 Queue consumer clusters ActiveMQ支持 ...
- ActiveMQ in Action(3) - Persistence
关键字: activemq 2.3 Persistence2.3.1 AMQ Message Store AMQ Message Store是ActiveMQ5.0缺省的持久化存储.Messag ...
- ActiveMQ in Action(2) - Transport
关键字: activemq 2.2 Transport ActiveMQ目前支持的transport有:VM Transport.TCP Transport.SSL Transport.Peer ...
- ActiveMQ in Action(1) - JMS
关键字: activemq 1 JMS 在介绍ActiveMQ之前,首先简要介绍一下JMS规范.1.1 JMS的基本构件1.1.1 连接工厂 连接工厂是客户用来创建连接的对象,例如Acti ...
- 《ActiveMQ in Action》例子
本章内容: 介绍本书中所有例子的使用场景 使用 Maven 编译.运行例子 例子中怎么使用 ActiveMQ 简介 ActiveMQ 不仅实现了 JMS 规范中定义的所有特性,也额外提供了一些特有且有 ...
- 4.3.5 使用Http:// (Https://)协议连接到ActiveMQ 2015年9月28日
用到的几点地方: 1.服务器端 ActiveMQ的文件activemq.xml中,预先要定义好有关本协议http的传输连接器格式,抓图如下: 2. 然后,开启Eclipse环境,在publish ...
随机推荐
- Vim扩展YouCompleteMe插件
在Vim中安装YouCompleteMe插件 一.安装前的说明: 1.确保vim版本>=7.4,若MAC OS,建议直接安装MacVim(8.0版本). ps:如果不想使用MacVim的GUI, ...
- django 学习笔记(一)搭建基础环境
1.安装django 下载地址 https://github.com/django/django 解压后进入文件夹运行指令 >> python setup.py install 2.创建工 ...
- 反编译与调试APK
0×01前言 这年头,apk全都是加密啊,加壳啊,反调试啊,小伙伴们表示已经不能愉快的玩耍了.静态分析越来越不靠谱了,apktool.ApkIDE.jd GUI.dex2jar等已经无法满足大家的需求 ...
- springmvc框架下ajax请求传参数中文乱码解决
springmvc框架下jsp界面通过ajax请求后台数据,传递中文参数到后台显示乱码 解决方法:js代码 运用encodeURI处理两次 /* *掩码处理 */ function maskWord( ...
- java 基本数据类型跟封装类型的差距
import java.util.*; class test1{ public static void main(String[] args){ long start1 = System.curren ...
- [安全学习环境]Win7 下DVWA安装指南
一.环境依赖: .Net Framework 3.5 PHP+MySQL 集成测试环境:XAMPP V3.2.1 二.环境准备 1.下载XAMPP(http://www.wampserver.com/ ...
- 2.开启TFTP,NFS,SAMBA,SSH服务
一.TFTP (1)dpkg -s tftp-hpa查看服务器端是否安装 (2)如果没安装 sudo apt-get install tftpd-hpa sudo apt-get install tf ...
- Form标签+Css基础
一.Form表单标签 <form action="" method=""></form> 表单就是用来将用户的信息提交到服务器 ...
- How I Mathematician Wonder What You Are!(poj 3130)
题意:求问多边形的核(能够看到所有点的点)是否存在. /* 对于这样的题目,我只能面向std编程了,然而还是不理解. 算法可参考:http://www.cnblogs.com/huangxf/p/40 ...
- rocketmq(1)
参考: 开源社区:https://github.com/alibaba/RocketMQ rocketmq入门: http://www.cnblogs.com/LifeOnCode/p/4805953 ...