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
主要是对队列,主题等功能细分,在一般常见中很少使用。
#引用文章
相关推荐
- **方案设计**:使用ActiveMQ作为消息中间件,实现与数据采集系统的解耦。 - **消息处理**: - 设备上下线消息:进行转换、校验后存储至MySQL。 - 定位消息:经过转换、校验及业务处理后存储至Elasticsearch。 ...
4. **集成Activemq**:ActiveMQ是Apache组织的一个开源项目,提供了一种消息中间件服务,支持多种消息协议。在本项目中,可能作为消息代理,处理应用程序之间的消息传递,使得消息通知更高效、可靠。 5. **消息通知...
消息队列,如RabbitMQ、Kafka或ActiveMQ,作为一个中间件,可以接收和暂存秒杀请求,而不是立即转发到数据库。业务服务器响应用户提示订单正在处理中,然后异步地从消息队列中取出请求进行处理,如校验库存和生成...
- **消息队列**:Spring与各种消息中间件(如ActiveMQ、RabbitMQ等)集成,便于实现消息驱动的应用场景。 #### 三、Spring MVC 1. **MVC模式**:Spring MVC遵循MVC设计模式,将应用程序分为Model、View和...
5. **消息队列**:介绍ActiveMQ、RabbitMQ、RocketMQ和Kafka这四种常见的消息中间件,讲解如何在Spring Boot中实现异步通信。 6. **异常处理、应用监控与安全**:包括错误处理策略,使用Spring Boot Actuator进行...
Redis是一个开源的内存数据结构存储系统,常被用作数据库、缓存和消息中间件。正则表达式可以用于Redis的键值匹配和数据验证。 Ftp(文件传输协议)相关的操作经常涉及到文件路径和文件名的处理,正则表达式可以...
2. **中间件或消息队列**:使用如RabbitMQ、Kafka或ActiveMQ等消息中间件,当数据更新时,通过发布订阅模式将变更事件发送到队列,其他数据库监听这个队列并进行相应的更新。这种方法增加了系统复杂性,但能实现异步...