如何在Qpid中设置安全提供程序以允许匿名身份验证以及名称/密码身份验证? [英] How do I set up a security provider in Qpid to allow anonymous and also name/password authentication?

查看:195
本文介绍了如何在Qpid中设置安全提供程序以允许匿名身份验证以及名称/密码身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我使用Apache Proton和Qpid(java-broker版本0.32)的第一天,我需要一个简单的Java发送和接收示例(无JMS).通过四处浏览,我发现Send.java和Recv.java都不起作用.

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.

在"mng.send()上,我得到

On "mng.send() I get

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

从stackoverflow和其他六个Google搜索看来,必须首先创建一个匿名"安全提供程序.

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

这是怎么做到的?我既无法猜测config.json的更改,也无法猜测如何使用Web界面. Qpid Java Broker文档中的两句prose对我没有帮助.

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.

在相关说明中,我不能只使用"amqp://admin:admin @ localhost:5672"(或amqps://admin:admin @ localhost吗?)并利用已经提供的安全提供程序在那里吗?

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?

是否有人有记载有Java的Send and Recv示例,已知该示例实际上在当前版本的Qpid和Proton上运行,并且附带任何必要的config.json更改?

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?

推荐答案

带有QPID Proton库的QPID Java Broker可以正确进行匿名身份验证.

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

请按照以下步骤操作,以避免QPID Java Broker 0.32的连接中止.

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

  1. 登录到Broker本地网页,例如locahost:8080,使用您的管理员用户名和密码
  2. 转到代理"标签,然后向下滚动以找到身份验证提供程序"
  3. 并单击添加提供者",输入以下详细信息并保存, 名称:匿名 类型:匿名

  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

现在,再次转到代理"选项卡,然后向下滚动以找到端口"-AMQP.单击AMQP进行编辑.从下拉菜单中选择您在上面的步骤3中创建的身份验证提供程序",然后保存.

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.

尝试您的测试代码

在需要的情况下,这里是工作样本:

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;
}

这篇关于如何在Qpid中设置安全提供程序以允许匿名身份验证以及名称/密码身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆