【问题标题】:JMSWMQ2013 error and WAS QCF ignoring JAAS auth to connect to MQJMSWMQ2013 错误和 WAS QCF 忽略 JAAS 身份验证以连接到 MQ
【发布时间】:2018-12-05 15:40:26
【问题描述】:

当 WAS QCF 尝试连接到 MQ 时,我收到以下错误,经过数小时的调查发现 QCF 忽略了给它的 JAAS 身份验证,而是使用自己的方法获取 WAS user.name 并将其传递给 MQ获得连接,但失败了……有谁知道为什么 WAS QCF 在这里忽略了 JAAS 身份验证。我看到了一个post,但没有看到具体的答案。

错误:

JMSWMQ2013: The security authentication was not valid that was supplied for QueueManager 'QMGR' with connection mode 'Client' and host name 'qmgrhost(1431)'. Please check if the supplied username and password are correct on the QueueManager you are connecting to...JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED'). "

【问题讨论】:

  • 您能否提供一些关于如何配置 QCF、您的应用程序如何获取 QCF 以及如何定义资源引用的信息。
  • 查看 IBM 的此技术说明。基本上,如果您使用 JNDI 资源的直接查找,则 J2C 身份验证别名不会流向队列管理器,只有当您使用间接查找时才会使用身份验证别名。 IBM Technote: Enterprise applications, the WebSphere Application Server WebSphere MQ messaging provider connection factories and Authentication Aliases explained.
  • 使用直接查找,唯一的选择是将用户 ID 和密码传递给@Roger 建议的 createQueueConnection 方法,但技术说明描述了如何设置间接引用以允许使用间接查找并进行身份验证要流动的别名。
  • 如果这是您要查找的内容,我会写一个快速回答,重点介绍 Technote 的某些特定部分。
  • @Alasdair 1 .QCF 在客户端模式的集群范围内创建,并配置为使用 J2C 身份验证别名连接到 MQ。 2.应用程序使用indrect jndi查找在WAS中定位qcf以启动与mq的连接。

标签: jms websphere ibm-mq


【解决方案1】:

您需要将用户凭据传递给 QueueConnection,如下所示:

QueueConnection conn = cf.createQueueConnection(userID, password);
conn.start();

其中 cf 是 QueueConnectionFactory。

try
{
   Hashtable env = new Hashtable();
   env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
   env.put(Context.PROVIDER_URL, "file:/" + "some_path_to_mq_jndi"

   Context ctx = new InitialContext(env);

   cf = (QueueConnectionFactory) ctx.lookup("myQCF");
}
catch (NamingException e)
{
   System.err.println(e.getLocalizedMessage());
   e.printStackTrace();
   throw e;
}

【讨论】:

  • 我不建议在应用服务器中这样做。凭据应该来自容器环境,并且您应该从应用服务器管理的资源中获取连接工厂。
  • 您可以从任何您想要的地方获取连接工厂。关键是需要将用户凭据传递到 createQueueConnection 方法中。
猜你喜欢
  • 2013-09-28
  • 1970-01-01
  • 2013-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多