javax.security.sasl.SaslException:从远程客户端连接到 Jboss 7 服务器时认证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19129836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javax.security.sasl.SaslException: Authentic Failed while connecting to Jboss 7 server from remote client
提问by rockstar
I have standalone Java client(Running from within eclipse ) that I wish to connect to an external server . If the server is localhost then i see no problems at all . However whenever i try to connect to the external server where I always gets the following exception
我有独立的 Java 客户端(从 eclipse 中运行),我希望连接到外部服务器。如果服务器是本地主机,那么我看不到任何问题。但是,每当我尝试连接到外部服务器时,总是会出现以下异常
- JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
- Could not register a EJB receiver for connection to remote://10.160.148.61:4447
java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
I have tried to follow the steps mentioned EJB invocations from a remote client using JNDI
我已尝试使用 JNDI 从远程客户端执行 EJB 调用中提到的步骤
The exception tells me tthere is something wrong in my configuration files related to authentication . Here is my ejb_client_properties file
异常告诉我 tthere 我的配置文件中与身份验证相关的错误。这是我的 ejb_client_properties 文件
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=10.160.148.61
remote.connection.default.port = 4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=tan
remote.connection.default.password=f2b1c3c7d3f1e224cbf6508494cf0418
Note : the user tan is added to my mgt.user.properties file on the server . I used add-user.bat to add a user in the server . I also added an application user . I use the same credentials to pass to the server . I cant think of anything else .
注意:用户 tan 被添加到服务器上的 mgt.user.properties 文件中。我使用 add-user.bat 在服务器中添加用户。我还添加了一个应用程序用户。我使用相同的凭据传递给服务器。我想不出别的了。
My ejb calling is as follows :
我的 ejb 调用如下:
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
InitialContext aJNDI = new InitialContext(jndiProperties);
Ppi handle = (Ppi) aJNDI
.lookup("ejb:PPIEAR/PService/PConnect!com.gem.p.PConnection?stateful");
I see numerous threads related to the exception but unable to fix it :( Can someone help .
我看到许多与异常相关的线程,但无法修复它:( 有人可以帮忙吗?
I also have a legitimate SSL certificate installed on the server . Do i need to do something extra to take care of that ?
我还在服务器上安装了合法的 SSL 证书。我需要做一些额外的事情来解决这个问题吗?
Also NOTE : My server is running in standalone mode .
另请注意:我的服务器以独立模式运行。
采纳答案by rockstar
Ok I have been able to figure out the problem .
好的,我已经能够找出问题所在。
It was a case of the the application user being added incorrectly on the server side . Specifically see below .
这是在服务器端错误添加应用程序用户的情况。具体见下文。
[userone@localhost bin]$ ./add-user.sh
What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): b
Enter the details of the new user to add.
Realm (ApplicationRealm) : ApplicationRealm ---->> Careful Here . You need to type this or leave it blank . I filled an incorrect value here and things went wrong from there .
Username : testuser
Password : testpassword
Re-enter Password : testpassword
What roles do you want this user to belong to? (Please enter a comma separated list, or leave blank for none) : testrole
About to add user 'testuser' for realm 'ApplicationRealm'
Is this correct yes/no? yes
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-users.properties'
Added user 'testuser' to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-users.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/standalone/configuration/application-roles.properties'
Added user 'testuser' with roles testrole to file '/home/userone/jboss-as-7.1.0.Final/domain/configuration/application-roles.properties'
.
.
I took me a long time to figure this out . Helpful link for the same :: http://middlewaremagic.com/jboss/?p=1466
我花了很长时间才弄明白这一点。相同的有用链接 :: http://middlewaremagic.com/jboss/?p=1466
回答by eis
One option is to do
一种选择是做
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.SECURITY_PRINCIPAL, username);
jndiProperties.put(Context.SECURITY_CREDENTIALS, password);
InitialContext aJNDI = new InitialContext(jndiProperties);
with a username that has access.
具有访问权限的用户名。
The same can be provided in jndi.properties, see documentation
可以在 jndi.properties 中提供相同的内容,请参阅文档