4 Replies Latest reply on Jan 8, 2005 1:11 PM by Scott Tamosunas

    Getting the logged on user info

    Scott Tamosunas Newbie


      I am currently using a DatabaseServerLoginModule to authenticate into my web application. My login-config.xml has the following section:

       <application-policy name = "myRealm">
       <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
       <module-option name = "dsJndiName">java:/MyDS</module-option>
       <module-option name = "principalsQuery">select distinct password from principal p where p.username = ?</module-option>
       <module-option name = "rolesQuery">select r.name, 'Roles' FROM role r, principal p, principal_role pr where p.principal_id = pr.principal_id AND r.role_id = pr.role_id AND p.username = ?</module-option>
       <module-option name = "hashAlgorithm">MD5</module-option>

      This works just fine.

      Now, in a struts action, I would like to get the information about the logged on user. Specifically, I would like to get the principal_id that stored in the principal table that corresponds with the logged on user. What's the easiest way to do that?