JBoss Community

Re: Remote EJB Client Security (Jboss7.1)

created by rathm1 in JBoss AS 7 Development - View the full discussion

Thanks for the quick reply.

 

I have gotten rid of the jndi.properties files but still have the same error.

When I specify the username and password in the jboss-ejb-client.properties all is well but I don't want to have it hard coded so I am trying to set the username and password in the InitialContext.

 

My set up is now:

jboss-ejb-client.properties

 

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=localhost

remote.connection.default.port=4447

remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false

remote.connection.default.connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS=JBOSS-LOCAL-USER

 

Client Application Code:

 

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);

Context context = new InitialContext(jndiProperties); 

 

String lookUp = "ejb:" + appName + "/" + moduleName + "/" + beanName + "!" + interfaceClassName;

 

TestEJB facade = (TestEJB)context.lookup(lookUp);

boolean connectionSuccessful = facade.canConnect();

Reply to this message by going to Community

Start a new discussion in JBoss AS 7 Development at Community