JBoss Community

Re: Remote client access with database login module: user name and password are UUIDs

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

Hello,

I'm facing the same problem. In the client I use a LoginContext to pass the username/password to the context:

 

final Properties jndiProperties = new Properties();

 

jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:4447");

 

jndiProperties.put("jboss.naming.client.ejb.context", true);

jndiProperties.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");      

 

 

InitialContext context = null;

 

 

try

{

          Configuration.setConfiguration ( new LoginConfiguration ());

          Class<?> cb = Class.forName ( "org.jboss.security.auth.callback.UsernamePasswordHandler" );

          Constructor<?> c = cb.getConstructor ( new Class[] { String.class, char[].class });

          LoginContext lc = new LoginContext ( "other", ( CallbackHandler ) c.newInstance ( new Object[] { "fapiuser", "guest".toCharArray() }));

          lc.login();

 

          context = new InitialContext(jndiProperties);

 

          EJBObject ejbObject = (EJBObject) context.lookup("ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName);

          System.out.println("remote: " + ejbObject);

 

          ...

 

On server-side I use a custom login module:

 

public class CustomLoginModule extends UsernamePasswordLoginModule {

 

 

          protected String getUsersPassword() throws LoginException

  {

    final String username = super.getUsername();

    log.info( ">>> username: '" + username + "'" );

                    ...

          }

}

 

In JBoss logfile I also see the user name as a random UUID. Can somebody help me to solve this problem?

 

 

Regards,

Sebastian

Reply to this message by going to Community

Start a new discussion in JBoss AS 7 Development at Community