3 Replies Latest reply on Mar 6, 2003 9:50 AM by petertje

    DatabaseServerLoginModule -> difficulties

    mikewazowski

      Hi,

      I have some big trouble with the DatabaseServerLoginModule. I'm using JBoss 3.0.4.

      The connection to the database works fine. I tested it without a JAAS-module.

      My login-config.xml
      ---------------------------------------------------------
      ...
      <application-policy name = "mydb">

      <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
      <module-option name="dsJndiName">java:/MSSQLDS</module-option>
      <module-option name="principalsQuery">select passwort from TestEJB where username=?</module-option>
      <module-option name="rolesQuery">select role from TestEJB where username=?</module-option>
      </login-module>

      </application-policy>
      ...
      ---------------------------------------------------------

      My jboss.xml
      ---------------------------------------------------------
      ...
      <container-configuration>
      <container-name>Standard Stateless SessionBean</container-name>
      <security-domain>java:/jaas/mydb</security-domain>
      </container-configuration>
      ...
      ---------------------------------------------------------
      This error occurs when I try to start a Bean:
      ERROR [SecurityInterceptor] Authentication exception, principal=null

      Any ideas what do I have to change? I read a lot tutorials but there is no further information what else I can do?!

      thx mike :o)

        • 1. Re: DatabaseServerLoginModule -> difficulties

          > This error occurs when I try to start a Bean:

          When you start the bean?? Or do you mean "when the bean is called"? How do you call the bean (servlet, client app)?

          • 2. Re: DatabaseServerLoginModule -> difficulties
            mikewazowski

            Yes, it should be "calling the bean". I call it via client app.
            Here is my code-snippet:
            ---------------------------------------------------------
            ...
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            env.put(Context.SECURITY_PRINCIPAL, "username");
            env.put(Context.SECURITY_CREDENTIALS, "password");
            env.put(Context.PROVIDER_URL, "localhost:1099");
            env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");

            ctx = new InitialContext(env);
            ...
            ---------------------------------------------------------

            Thx, Mike :o)

            • 3. Re: DatabaseServerLoginModule -> difficulties

              The "JBoss way" to pass security credentials is not via the initial context (although for simplicity it is added lately; there was a post about this in this forum quite recently).
              The proper way is to let your client app do a Jaas login, using the jboss ClientLoginModule; this will set the security attributes for the bean call.

              Hth,
              Peter.