How do I set up a security provider in Qpid to allow anonymous and also name/password authentication?

ⅰ亾dé卋堺 提交于 2019-12-13 19:41:53

问题


This is my first day with Apache Proton and Qpid (java-broker version 0.32) and I need a simple send and receive example in Java (no JMS). By poking around I found Send.java and Recv.java neither of which actually work.

On "mng.send() I get

java.io.IOException: An established connection was aborted by the software in your host machine

From stackoverflow and a half dozen other google searches it seems that one must create an "anonymous" security provider first.

How does one do this? I can't guess either the config.json change nor how to use the web interface. The two sentences of prose in the Qpid java broker documentation are not helping me.

On a related note, couldn't I just use "amqp://admin:admin@localhost:5672" (or amqps://admin:admin@localhost ?) and take advantage of the security provider that is already there?

Does anyone have a documented Java example of Send and Recv that is known to actually run on the current version of Qpid and Proton and comes with any prerequisite config.json changes?


回答1:


QPID Java Broker with QPID Proton library works without error for anonymous authentication.

Please follow below steps to avoid connection abort for QPID Java Broker 0.32.

  1. Log on to Broker local web page e.g. locahost:8080 with your admin user and password
  2. Go to "Broker" tab and scroll down to locate "Authentication Providers"
  3. And click "Add Provider" enter following details and save, Name: anonymous Type: Anonymous

  4. Now again, go to "Broker" tab and scroll down to locate "Ports" - AMQP. Click AMQP to edit. Select "Authentication Provider" to the one you have created in step #3 above from the drop-down and save.

  5. Try your test code

Here is the working sample in case required:

private static final String address = "amqp://guest:guest@localhost:5672/"; // (format : QPIDPortName://user:password@host:port you may use admin:admin as well if not removed from default setting by your administrator) 
private static final String exchangeName = "MYTOPIC-EXCHANGE"; // First create this exchange in QPID Broker!
private static final String publishToAddress = new StringBuilder().append(address).append(exchangeName).toString();

public static boolean publishMessage(String msg)
{
    boolean isMsgDelivered = false;
    ApplicationProperties customAppProperties = null;
    try 
    {
        Messenger messenger = Proton.messenger();
        messenger.start();
        Message message = Proton.message();

        message.setAddress(publishToAddress);
        message.setContentEncoding("UTF-8");
        message.setContentType("text/plain");
        message.setSubject(exchangeName);
        Section sec = new AmqpValue(msg);
        message.setBody(sec);

        messenger.put(message);
        messenger.send();
        messenger.stop();
        isMsgDelivered = true;
    } 
    catch (Exception e) 
    {
        logger.log(Level.SEVERE, "Qpid Proton error: "+ e.getMessage(), e);
        e.printStackTrace();
    }

    return isMsgDelivered;
}



回答2:


To enable ANONYMOUS authentication, add an empty anonymous-auth-manager tag in the security section of your broker config:

<security>
  <anonymous-auth-manager/>
  ...
</security>

default location is ${QPID_HOME}/etc/config.xml




回答3:


The Java broker does not support anonymous authentication. I need to switch to the C++ broker.

Qid and Proton still needs a Java tutorial if only so the qpid team can test it.



来源:https://stackoverflow.com/questions/31643536/how-do-i-set-up-a-security-provider-in-qpid-to-allow-anonymous-and-also-name-pas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!