I get a ServeletException: Failed to authenticate a principal when I attempt to login with the DatabaseServerLoginModule. I\'m guessing the issue is either how
I was able to get help with this on the jboss as forums. My solution was to revise the markup of the rolesQuery from:
<module-option name="rolesQuery"
value="SELECT groupid, 'Roles' FROM grouptable WHERE username=?" />
to this:
<module-option name="rolesQuery">
SELECT groupid, 'Roles' FROM grouptable WHERE username=?
</module-option>
I also had to change the encoding style to HEX. Here is my working login-config.xml.
<application-policy name="Avengers">
<authentication>
<login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required">
<module-option name="dsJndiName">java:/jdbc/thor_ds</module-option>
<module-option name="principalsQuery">SELECT password FROM usertable WHERE username = ?</module-option>
<module-option name="rolesQuery">SELECT groupid, 'Roles' FROM grouptable WHERE username=?</module-option>
<module-option name="hashAlgorithm">MD5</module-option>
<module-option name="hashEncoding">HEX</module-option>
<!--<module-option name="hashEncoding">base64</module-option>-->
</login-module>
</authentication>
</application-policy>