经典版和Artemis都有自己的用户系统和默认的登录认证逻辑,但是当需要和业务系统集成,共享同一套用户/角色时,就需要自定义身份认证了。这里简单记录一下实现思路。
一、ActiveMQ经典版
1、自定义身份认证插件
- 新建maven工程,添加依赖
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.15.12</version>
<type>jar</type>
</dependency>
- 添加类,实现BrokerFilter的addConnection方法,完成登录验证。如果验证不通过,直接抛SecurityException异常即可。
- 添加类,实现BrokerPlugin的installPlugin方法,返回上一步的BrokerFilter对象。
- 编译为jar,放到activemq的/lib目录下
- 编辑conf/activemq.xml在broker节点下配置插件,重启activemq生效
<plugins>
<bean xmlns="http://www.springframework.org/schema/b%3C/code%3E%3C/pre%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3C/div%3E%20%20%20%20%20%20%20%20%3C/div%3E%20%20%20%20%3C/article%3E%20%20%3Cscript%3E%20%20%20%20$(function()%20%7B%20%20%20%20%20%20setTimeout(function%20()%20%7B%20%20%20%20%20%20%20%20var%20mathcodeList%20=%20document.querySelectorAll('.htmledit_views img.mathcode');
if (mathcodeList.length > 0) {
for (let i = 0; i < mathcodeList.length; i++) {
if (mathcodeList[i].complete) {
if (mathcodeList[i].naturalWidth === 0 || mathcodeList[i].naturalHeight === 0) {
var alt = mathcodeList[i].alt;
alt = '\\(' + alt + '\\)';
var curSpan = $('');
curSpan.text(alt);
$(mathcodeList[i]).before(curSpan);
$(mathcodeList[i]).remove();
}
} else {
mathcodeList[i].onerror = function() {
var alt = mathcodeList[i].alt;
alt = '\\(' + alt + '\\)';
var curSpan = $('');
curSpan.text(alt);
$(mathcodeList[i]).before(curSpan);
$(mathcodeList[i]).remove();
};
}
}
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
}, 500)
});
10-16
2734
2734
12-09
1175
1175

本文档记录了如何在ActiveMQ经典版和Artemis中实现自定义身份认证,包括自定义身份认证插件、jaas登录模块的创建以及配置步骤,以实现与业务系统的用户角色集成。

被折叠的 条评论
为什么被折叠?



