Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.security.sasl.SaslException: Authentic Failed while connecting to Jboss 7 server from remote client

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

- 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

The exception tells me tthere is something wrong in my configuration files related to authentication . Here is my ejb_client_properties file

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 .

My ejb calling is as follows :

        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 ?

Also NOTE : My server is running in standalone mode .

like image 200
rockstar Avatar asked Oct 02 '13 04:10

rockstar


2 Answers

Ok I have been able to figure out the problem .

It was a case of 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

like image 139
rockstar Avatar answered Sep 22 '22 18:09

rockstar


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

like image 42
eis Avatar answered Sep 24 '22 18:09

eis