1 Reply Latest reply on Mar 29, 2006 9:57 AM by Jens Elkner

    Username in DatabaseServerLoginModule is null

    Milen Angelov Newbie

      Hi there,
      I'm trying to auth user by using DatabaseServerLoginModule from JBoss, but I have exception:
      javax.ejb.EJBAccessException: Authentication failure
      ...
      Caused by: javax.security.auth.login.FailedLoginException: No matching username found in Principals.

      While debugging I found that in getUsersPassword function:

      // Get the password
      ps = conn.prepareStatement(principalsQuery);
      ps.setString(1, username);
      rs = ps.executeQuery();
      if( rs.next() == false )
      throw new FailedLoginException("No matching username found in Principals");

      username is null.


      What I have is:

      in login-config:

      <application-policy name = "pimpf-test">

      <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
      flag = "required">
      <module-option name = "unauthenticatedIdentity">guest</module-option>
      <module-option name = "dsJndiName">java:/OracleDS</module-option>
      <module-option name = "principalsQuery">SELECT PASSPHRASE FROM USERS WHERE USERNAME=?</module-option>
      <module-option name = "rolesQuery">SELECT ROLENAME, 'Roles' FROM ROLES WHERE USERNAME=?</module-option>
      </login-module>

      </application-policy>

      On the client side:

      props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");

      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");

      props.put(Context.SECURITY_PRINCIPAL, "pimpf");

      props.put(Context.SECURITY_CREDENTIALS, "testpass");


      and in DB:
      SELECT PASSPHRASE FROM USERS WHERE USERNAME = 'pimpf'

      PASSPHRASE
      -------------
      testpass

      Any ideas?