ActiveMQ authorization

后端 未结 2 856
别那么骄傲
别那么骄傲 2021-01-01 05:14

If I want to implement JAAS authorization on Apache ActiveMQ, do I have to use the plug-in in the activemq.xml configuration file?

This way is really NOT good becaus

2条回答
  •  生来不讨喜
    2021-01-01 05:35

    I found some code snippets that ended up being tremendously helpful in getting started on this subject:

    http://activemq.2283324.n4.nabble.com/Fully-programmatic-authorization-map-tp2344815.html

    Here's how I ended up using it (may not be the best way):

    public class TestAuthorizationPlugin extends AuthorizationPlugin {
    

    Then:

    @Override
    public Broker installPlugin(Broker broker) {
        List entries = new ArrayList(); 
        try {
            entries.add(makeTopicAuthorization("groupA.topic", "groupA", "groupA", "groupA"));
            entries.add(makeQueueAuthorization("groupA.queue", "groupA", "groupA", "groupA"));
            entries.add(makeQueueAuthorization("groupB.queue", "groupB", "groupB", "groupB"));
            entries.add(makeTopicAuthorization("ActiveMQ.Advisory.>", "all", "all", "all"));
            AuthorizationMap authMap = new DefaultAuthorizationMap(entries);
            return new AuthorizationBroker(broker, authMap);
        } catch (Exception e) {
            LOGGER.error(e);
        } 
    
        return new AuthorizationBroker(broker, null);
    }
    

    jar this and stick it in /lib/.

    Modify the activemq.xml:

    
        
        
    
        
        
    
    

    Another helpful link for more info on autho plugin dev:

    http://mariuszprzydatek.com/2014/01/04/token-based-authentication-plugin-for-activemq/

提交回复
热议问题