1 Reply Latest reply on Jul 22, 2002 11:56 AM by lateef

    DatabaseServerLoginModule Debugging:

    lateef

      DatabaseServerLoginModule Debugging:
      So I got the example working from
      http://www.javaworld.com/javaworld/jw-08-2001/jw-0831-jaas.html
      And it works beutifully :) Many thanks to all the Jboss peeps.
      I am trying to integrate it with a PHP application which uses MD5 hash to authenticate the users. We have store the username, password in a Postgresql database so I was able to use subselect so the the correct information. I have tested the queries manually but I still get this error:

      11:19:22,868 ERROR [DatabaseServerLoginModule] Query failed
      org.jboss.util.NestedSQLException: No matching credentials in Subject!; - nested throwable: (javax.resource.ResourceException: No matching credentials in Subject!)
      at org.jboss.resource.adapter.jdbc.local.LocalDataSource.getConnection(LocalDataSource.java:106)
      at org.jboss.security.auth.spi.DatabaseServerLoginModule.getUsersPassword(DatabaseServerLoginModule.java:96)
      at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:142)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:664)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:129)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:599)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokeModule(LoginContext.java:596)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:523)
      at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecurityManager.java:381)
      at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecurityManager.java:347)
      at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:215)
      at org.jboss.jetty.security.JBossUserRealm$JBossUserPrincipal.isAuthenticated(JBossUserRealm.java:72)
      at org.jboss.jetty.security.JBossUserRealm$JBossUserPrincipal.authenticate(JBossUserRealm.java:133)
      at org.jboss.jetty.security.JBossUserRealm.authenticate(JBossUserRealm.java:232)
      at org.mortbay.http.HttpRequest.basicAuthenticated(HttpRequest.java:1018)
      at org.mortbay.http.handler.SecurityHandler$BasicAuthenticator.authenticated(SecurityHandler.java:79)
      at org.mortbay.http.SecurityConstraint.check(SecurityConstraint.java:297)
      at org.mortbay.http.handler.SecurityHandler.handle(SecurityHandler.java:302)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1387)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1326)
      at org.mortbay.http.HttpServer.service(HttpServer.java:757)
      at org.jboss.jetty.Jetty.service(Jetty.java:527)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:742)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:915)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:757)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:151)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:715)
      at java.lang.Thread.run(Thread.java:536)
      Caused by: javax.resource.ResourceException: No matching credentials in Subject!
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.getConnectionProperties(LocalManagedConnectionFactory.java:379)
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:117)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnection(InternalManagedConnectionPool.java:236)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:101)
      at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:312)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:467)
      at org.jboss.resource.connectionmanager.LocalTxConnectionManager.getManagedConnection(LocalTxConnectionManager.java:221)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:532)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:812)
      at org.jboss.resource.adapter.jdbc.local.LocalDataSource.getConnection(LocalDataSource.java:102)
      ... 33 more
      11:19:22,926 WARN [JBossUserRealm#JAAS Tutorial Servlets] authentication failure: foo
      11:19:22,930 WARN [Jetty] WARNING: AUTH FAILURE: user foo


      So I have attached my login-config.xml. The important part is:
      <application-policy name = "client-login">

      <login-module code = "org.jboss.security.ClientLoginModule"
      flag = "required">
      </login-module>

      </application-policy>

      <application-policy name = "example2">

      <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
      <module-option name="dsJndiName">java:/SSC_DS</module-option>
      <module-option name="principalQuery">SELECT password FROM users name WHERE name=?</module-option>
      <module-option name="roleQuery"> SELECT name FROM permission WHERE id IN (SELECT permission FROM users_permission WHERE users IN (SELECT id FROM users WHERE name=?))</module-option>
      <module-option name="hashAlgorithm">MD5</module-option>
      <module-option name="hashEncoding">base64</module-option>
      </login-module>

      </application-policy>

      Does anyone know how I could debug this? Do I need to start hacking DatabaseServerLoginModule?

      Many thanks for any help.
      Lateef

        • 1. Re: DatabaseServerLoginModule Debugging:
          lateef

          The posting error report is incorrect. Sorry friday afternoon messup.
          My problem basically is I want to find out what is comming out of the MD5 algorithm to compare it to what is actually stored in the DB.

          The only informaiton I get is:
          11:03:57,542 WARN [JBossUserRealm#JAAS Tutorial Servlets] authentication failure: test
          11:03:57,544 WARN [Jetty] WARNING: AUTH FAILURE: user test

          I would like to know what password is being returned from the query and what the MD5 encrypted password is?

          Many Thanks.
          Lateef