ActiveMQ Artemis ActiveMQSecurityManager4 验证 ClientID/Subscription

ActiveMQ Artemis ActiveMQSecurityManager4 verify ClientID/Subscription

目前 Artemis 拥有 ActiveMQSecurityManager4。使用以下方法时,它提供了很多控制权:

/**
* Determine whether the given user is valid and whether they have
* the correct role for the given destination address.
*
* This method is called instead of
* {@link ActiveMQSecurityManager#validateUserAndRole(String, String, Set, CheckType)}.
*
* @param user       the user
* @param password   the user's password
* @param roles      the user's roles
* @param checkType  which permission to validate
* @param address    the address for which to perform authorization
* @param remotingConnection the user's connection
* @param securityDomain the name of the JAAS security domain to use (can be null)
* @return the name of the validated user or null if the user isn't validated
*/
String validateUserAndRole(String user,
                          String password,
                          Set<Role> roles,
                          CheckType checkType,
                          String address,
                          RemotingConnection remotingConnection,
                          String securityDomain);

当客户端连接并尝试创建订阅时,有没有办法知道他的 ClientID/Subscription 姓名? (CheckType=CREATE_DURABLE_QUEUE over address="org.activemq.premium.news" )

我想控制允许谁订阅给定地址 (TOPIC) 并保证订阅属于初始(经过身份验证的)订阅者。

编辑 1:

调用方法有队列(clientID+subs name) 但我认为不能扩展

/**
* The ActiveMQ Artemis SecurityStore implementation
*/
public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryChangeListener {

...

@Override
public void check(final SimpleString address,
                  final SimpleString queue,  //exactly what I was looking for
                  final CheckType checkType,
                  final SecurityAuth session) throws Exception {
...

编辑 2:

场景

我有 Bob (user:bob, pass: bob) 和 Alice (user:Alice, pass:Alice),每个人都会创建与代理的连接以进行订阅,比方说 address="org.activemq.premium.news”。到目前为止,我可以阻止其中之一到达该地址,这还不错。现在我想要两个都订阅(每个都有一个队列),但我想确保 Bob 的订阅名为“bob”,Alice 的订阅名为“alice”。我不希望如果爱丽丝先订阅,它会使用“bob”作为订阅名称。也不确定规范是否保证在 Bob 的初始订阅之后,如果他没有连接,Alice 不能使用他的订阅名称来使用他的消息——即订阅队列绑定到该用户。

我想你想做的事情已经通过 ARTEMIS-592 解决了。您只需要在 broker.xml 中的相关 security-setting 中将地址和队列名称与 . 字符连接起来。一定要把应该隔离的用户分到不同的组。

明确地说,您不需要实施安全管理器或插件或类似的东西。您应该能够通过配置处理您需要的一切。

由于 https://issues.apache.org/jira/browse/ARTEMIS-2886 更改,我的初始要求现在可以实现了。