我们的代码在weblogic和MQ 6.0中运行。无论我使用默认的createQueueConnection()
还是createQueueConnection("myuserid","mypassword")
,它似乎总是使用用户ID mqm
。请参阅下面的代码。
当我从6.0版连接到较旧的mq installion 5时,似乎使用默认的javax.jms.JMSSecurityException: MQJMS2013: invalid security authentication supplied for MQQueueManager
抛出以下错误createQueueConnection()
,除非我发送空白的用户ID /密码,如createQueueConnection("","")
如何才能发送myuserid?
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,context);
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory");
InitialContext ctx = new InitialContext(properties);
QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("QCF");
QueueConnection qc = qcf.createQueueConnection();
javax.jms.Queue q = (javax.jms.Queue) ctx.lookup("MYQUEUE");
QueueSession qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
TextMessage tm = qs.createTextMessage();
tm.setText(outString);
QueueSender sender = qs.createSender(q);
sender.send(tm);
sender.close();
qs.close();
qc.close();
答案 0 :(得分:3)
如果您在createQueueConnection中设置ID,请放心, 将被呈现给队列管理器。您遇到的问题是QMgr 上的SVRCONN通道定义具有硬编码的值MCAUSER('mqm')。这将覆盖客户端应用程序提供的任何值。
这里有几点需要注意。
有关此主题的更多内容以及IMPACT的WMQ安全演示和WMQ安全实验室指南的指示,请参阅this SO question。