javax.security.sasl.SaslException:从远程客户端连接到Jboss 7服务器时,身份验证失败


问题内容

我有一个独立的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

我尝试按照提到的步骤使用JNDI从远程客户端进行EJB调用

该异常告诉我,在与身份验证相关的配置文件中出了点问题。这是我的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

注意:棕褐色用户已添加到服务器上的我的mgt.user.properties文件中。我使用add-
user.bat在服务器中添加了一个用户。我还添加了一个应用程序用户。我使用相同的凭据传递到服务器。我想不出什么了。

我的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");

我看到许多与异常相关的线程,但无法解决:(有人可以帮忙。

我还在服务器上安装了合法的SSL证书。我需要做些额外的事情来解决这个问题吗?

另请注意:我的服务器正在独立模式下运行。


问题答案:

好吧,我已经能够找出问题所在。

这是在服务器端错误地添加了应用程序用户的情况。具体见下文。

[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'

.

.

我花了很长时间才弄清楚这一点。相同的有用链接::
http://middlewaremagic.com/jboss/?p=1466