Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Authentication Glassfish JMS(平面文件)身份验证_Authentication_Glassfish_Jms_Passwords_Credentials - Fatal编程技术网

Authentication Glassfish JMS(平面文件)身份验证

Authentication Glassfish JMS(平面文件)身份验证,authentication,glassfish,jms,passwords,credentials,Authentication,Glassfish,Jms,Passwords,Credentials,在Glassfish上很容易设置平面文件JMS身份验证(请参阅) 问题在于客户机部分。我正在编写一个独立的Java客户端,通过JNDI访问我的JMS资源(ConnectionFactory和Destination) 如何从该客户机向JMS传递用户名和密码 我已经尝试了以下几种方法: 1) 在InitialContext中添加这些凭据 context.addToEnvironment(InitialContext.SECURITY_PRINCIPAL, "username"); context

在Glassfish上很容易设置平面文件JMS身份验证(请参阅)

问题在于客户机部分。我正在编写一个独立的Java客户端,通过JNDI访问我的JMS资源(
ConnectionFactory
Destination

如何从该客户机向JMS传递用户名和密码

我已经尝试了以下几种方法:

1) 在InitialContext中添加这些凭据

 context.addToEnvironment(InitialContext.SECURITY_PRINCIPAL, "username");
 context.addToEnvironment(InitialContext.SECURITY_CREDENTIALS, "password");
2) 在连接工厂中使用JMS用户名和密码参数

 connectionFactory.createConnection();
然而,这些方法都不起作用

当我运行程序时,我只得到:

com.sun.messaging.jms.JMSSecurityException: [C4084]: Échec de 
l'authentification de l'utilisateur :  user=guest, broker=localhost:7676(34576) 
at com.sun.messaging.jmq.jmsclient.ProtocolHandler.authenticate
(ProtocolHandler.java:1084)
因此,它不断尝试与“来宾”用户进行身份验证

对于这个测试,我使用
connection.NORMAL.deny.user=*
作为权限规则(
accesscontrol.properties

有趣的是,即使在获得连接因子之前也会引发此异常:

 InitialContext context = new InitialContext();

 ConnectionFactory connectionFactory = 
 (ConnectionFactory)context.lookup("jms/middleware/factory"); 
 /* The exception is thrown here, so authentication MUST have happened 
    before already (i.e. NOT in the createConnection(username, password) method) */
希望有人知道答案

非常感谢

问候,


Dinesh

好的,我找到了一个解决方法,即不使用JNDI,而是使用特定于供应商的JMS API,如中所述

最后的代码是:

com.sun.messaging.ConnectionFactory connectionFactory = new com.sun.messaging.ConnectionFactory();
QueueConnection queueConnection = connectionFactory.createQueueConnection("user01", "password01");
这一次导致了错误

Error: [C4060]: Login failed:  user=user01, broker=localhost:7676(53445)
这很好;)

因此,变通办法正在发挥作用。然而,如果有人知道如何通过JNDI实现这一点,那就更好了