2 Replies Latest reply on Oct 29, 2002 1:51 AM by mike.pettit

    principal=null  problem/bug with example.

    mike.pettit

      Hi all -

      I have been working on this for a few weeks now and I see a bunch of other people have the same problem. Apparently everything is set up correctly and you go to log into your app and hit an EJB and you get Authentication exception, principal=null.

      Ok - so i went ahead and built a small zip file with all my source java files and the deployment descriptors. Hopefully this open source community thing will work and someone can take a look at this. Yes, I know, my coding style isn't going to win any awards.

      Directions:
      configure a login datasource called "JDBCLogin" (see below)

      unzip attached file (hope this works)
      drop the test.ear into your JBoss directory.
      http://localhost:8080/test/SecurityTestServlet?username=userdude&password=atlanta

      Hopefully it will (not) work for you. By (not) work I mean that you will be able to see a bunch of printlns in your console and then "bam!" Authentication exception.

      N.b. The build.xml is messier than the java code ;)

      in my conf/login-config.xml (kludge)

      <application-policy name = "JDBCLogin">

      <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
      <module-option name = "dsJndiName">java:/substanceManagerDataSource</module-option>
      <module-option name = "principalsQuery">Select 'atlanta' password From Person where SEARCHNAME =?</module-option>
      <module-option name = "rolesQuery">SELECT 'SARVER_caller', 'CallerPrincipal' FROM DUAL UNION Select 'Echo' role, 'Roles' rolegroup From Person where SEARCHNAME =?</module-option>
      </login-module>

      </application-policy>


        • 1. here are the files
          mike.pettit

          Trying to attach a zip...

          • 2. Re: principal=null  problem/bug with example.
            mike.pettit

            Ok... Making progress here.

            I needed to add ejb-ref tags in my web.xml and jboss-web.xml deployment descriptors.

            I am still having a "CallerPrincipal" problem.
            I am using the DatabaseLoginModule with this:
            <module-option name = "rolesQuery">SELECT 'SARVER_caller', 'CallerPrincipal' FROM DUAL UNION Select 'Echo' role, 'Roles' rolegroup From Person where SEARCHNAME =?</module-option>

            That bogus CallerPrincipal select automatically populates my CallerPrincipal role... which is nice, but I want to do that in my code.

            With the "rolesQuery" statement like that - it seems to work. If I remove that select, I am back to CallerPrincipal=null.

            Some JBoss documentation states that is this role is not populated, then the SessionContext CallerPrincipal defaults to the applications' callerPrincipal - something like that...
            Apparently this is not the case....or I have to do something in my code to populate the CallerPrincipal role and associate that role with the SessionCOntext.

            How the heck do i do that?