- 浏览: 478819 次
- 性别:
- 来自: 大连
文章分类
最新评论
-
龘龘龘:
TrueBrian 写道有个问题,Sample 1中,为了控制 ...
What's New on Java 7 Phaser -
龘龘龘:
楼主总结的不错。
What's New on Java 7 Phaser -
TrueBrian:
有个问题,Sample 1中,为了控制线程的启动时机,博主实际 ...
What's New on Java 7 Phaser -
liguanqun811:
不知道楼主是否对zookeeper实现的分布式锁进行过性能测试 ...
Distributed Lock -
hobitton:
mysql的get lock有版本限制,否则get lock可 ...
Distributed Lock
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>
基于以上的配置,在JAAS的LoginContext中会使用activemq-domain中配置的PropertiesLoginModule来进行登陆。
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; } }
以下是ActiveMQ配置文件的一个例子:
<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>
在这个配置文件中增加了一个namespace auth,用于指向之前编写的哪个类。同时为SimpleAuthBroker注入了两个属性值user和password,因此在被SimpleAuthBroker改写的addInterceptors方法里,可以使用这两个属性进行认证了。ActiveMQ提供的SimpleAuthenticationBroker类继承自BrokerFilter(可以简单的看成是Broker的Adaptor),它的构造函数中的两个Map分别是userPasswords和userGroups。 SimpleAuthenticationBroker在 addConnection方法中使用userPasswords进行认证,同时会把userGroups的信息保存到ConnectionContext中 。
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>
发表评论
-
Terracotta in Action (3)
2009-03-25 09:20 50903 Inside Terracotta 3.1 Core T ... -
Terracotta in Action (2)
2009-03-21 21:09 46192. Terracotta Eclipse Plugin ... -
Terracotta in Action (1)
2009-03-19 21:52 62441. Introduction Terraco ... -
OpenEJB (4)
2008-05-11 09:05 3138本文部分内容节选自Enterprise JavaBeans 3 ... -
OpenEJB (3)
2008-05-11 09:04 2692本文部分内容节选自Enterprise JavaBeans 3 ... -
OpenEJB (2)
2008-05-11 09:03 3284本文部分内容节选自Enterprise JavaBeans 3 ... -
OpenEJB (1)
2008-05-10 22:39 5070本文部分内容节选自Enterprise JavaBeans 3 ... -
OpenJPA (7)
2008-03-25 21:56 351610 Miscellaneous Features 10 ... -
OpenJPA (6)
2008-03-23 21:33 62558 Object Locking 8.1 Configu ... -
OpenJPA (5)
2008-03-18 22:38 49607 Inheritance 对象使用引用以便关联到其 ... -
OpenJPA (4)
2008-03-11 23:27 70416 Query 6.1 JPQL Queries 6.1. ... -
OpenJPA (3)
2008-03-09 23:09 51954 EntityManagerFactory 4.1 Ove ... -
OpenJPA (2)
2008-03-05 23:59 72513 Metadata 通过javax.persist ... -
OpenJPA (1)
2008-03-04 23:11 68301 Overview Apache OpenJPA是 ... -
ActiveMQ in Action (7)
2008-02-27 14:33 126332.6.7 Wildcards Wil ... -
ActiveMQ in Action (6)
2008-02-26 15:22 137342.6 Features ActiveMQ包含了很多 ... -
ActiveMQ in Action (5)
2008-02-26 00:35 135332.5 Clustering ActiveMQ从多种 ... -
ActiveMQ in Action (3)
2008-02-26 00:16 105922.3 Persistence 2.3.1 AMQ Mess ... -
ActiveMQ in Action (2)
2008-02-25 23:58 132182.2 Transport ActiveMQ目前支持 ... -
ActiveMQ in Action (1)
2008-02-25 23:18 237871 JMS 在介绍ActiveMQ ...
相关推荐
ActiveMQ In Action及其源码 本来想免费提供下载的,但是发现csdn不能选择0积分下载,坑的很
ActiveMQ in Action pdf英文原版加源代码压缩包。 Apache ActiveMQ in Action is a thorough, practical guide to implementing message-oriented systems in Java using ActiveMQ. The book lays out the core of ...
ActiveMQ in Action的开发文档
这是最新版的《ActiveMQ in Action》包括第7、9、11、13等章节
activeMq in action 使用activeMq开发JMS的简单讲述,activeMq in action 使用activeMq开发JMS的简单讲述
ActiveMQ in Action 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
ActiveMQ In Action翻译笔记-更新版2011
activemq in action PDF 英文版 源代码 合二为一,目前好像只有英文版,源代码一起发布的少。我收集到了,分享给大家。 这本书讲得真是不错,英文看起来也不难,希望对你有帮助 。
ActiveMQ In Action的精简版
ActiveMQ 不仅实现了 JMS 规范中定义的所有特性,也额外提供了一些特有且有用的特性。我们会在 3.1 小节详细列说这些特性,并且书中剩余的章节还会继续讨论这些特性。为了演示这些特性,我们创建了两个基于实际业务...
ActiveMQ_in_Action_中文ActiveMQ_in_Action_中文ActiveMQ_in_Action_中文ActiveMQ_in_Action_中文
ActiveMQ in Action
经典的学习ActiveMQ的书籍。这本书讲得真是不错,英文看起来也不难,希望对你有帮助 。
ActiveMQ In Action.zip
ActiveMQ_in_Action.pdf 教程文档
activemq in action - activemq in action
ActiveMQ_in_Action_中文.zip
ActiveMQ+In+Action翻译笔记-+更新版2011.pdf
ActionMQ In Action 就是网上可以下载的那个版本, 不知道作者是谁,和英文版的书应该不是一回事。在原版的基础上增加了书签,可以看的更方便。这本书对ActiveMQ入门到一般的管理非常有帮助。