首页 > 其他 > 详细

消息中间件(4)-ActiveMQ安全校验

时间:2015-11-25 02:10:05      阅读:326      评论:0      收藏:0      [点我收藏+]

ActiveMQ安全机制的介绍

安全机制一般包含验证(Authentication)和授权(Authorization)两部分。在ActiveMQ中,验证指通过访问者的用户名和密码实现用户身份的验证,授权指为消息目标(队列或主题)的读、写、管理指定具有相应权限的用户组,并为用户分配权限。ActiveMQ的安全机制基于插件实现。

ActiveMQ提供两种验证插件,分别是:

1)Simple authentication plugin-in;

2)JAAS(Java Authentication and Authorization Service)authentication plugin-in。

ActiveMQ提供一种授权插件:Authorization plugin-in。

一、简单的安全认证(使用SimpleAuthenticationPlugin)?
(1)设置证书文件,放用户名和密码:${activemq.conf}/credentials.properties?

?
activemq.username=system
activemq.password=manager
(2)配置simpleAuthenticationPlugin,简单认证插件?
<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core 
  http://activemq.apache.org/schema/core/activemq-core.xsd">
	
? ? ?<!--加载属性配置文件-->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>
	
  
  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
	<!--在Broker中,配置插件-->
	<plugins> 
		<simpleAuthenticationPlugin> 
			<users> 
				<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/> 
			</users> 
		</simpleAuthenticationPlugin> 
	</plugins> 

	......
  </broker>
  
</beans>
?
(3)、在ConnectionFactory 初始化时
@Bean
 public PooledConnectionFactory PooledConnectionFactory(){
  ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
  connectionFactory.setBrokerURL(MQ_URL);
  connectionFactory.setUserName("system"); //用户名
  connectionFactory.setPassword("manager"); //密码
 
  PooledConnectionFactory PooledConnectionFactory = new PooledConnectionFactory();
  PooledConnectionFactory.setConnectionFactory(connectionFactory);
 
  return PooledConnectionFactory;
 }
?
二、JAAS 太过繁琐?
三、Authorization plugin-in?
主要是对队列,主题等功能细分,在一般常见中很少使用。
?
#引用文章

消息中间件(4)-ActiveMQ安全校验

原文:http://haoran-10.iteye.com/blog/2258898

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!