1 Reply Latest reply on Apr 17, 2013 12:43 AM by klind

    Database login with postgresql bytea column

    klind Newbie

      Hi, I have an existing postgresql database where the password is store in a bytea column.




      I am having trouble getting the database login to work.



      <login-module code="Database" flag="required">
           <module-option name="dsJndiName" value="java:jboss/jsi/JSIXADataSource"/>
           <module-option name="principalsQuery" value="select password from users where username = ?"/>
           <module-option name="rolesQuery" value="select userRoles,'Roles' from userroles where username=?"/>
           <module-option name="hashAlgorithm" value="SHA-512"/>
           <module-option name="hashEncoding" value="hex"/>
           <module-option name="hashUserPassword" value="true"/>


      If I insert a user with


      insert into users values ('klind', digest('pass1234', 'SHA512'));


      it does not work.. but if I do


      insert into users values ('klind', encode(digest('pass1234', 'SHA512'), 'hex'));


      it works.


      But of cause the users are not created this way, they are create in the web app.

      When the password from the user is saved into the database, it is hashed...


       MessageDigest md = null;
              try {
                  md = MessageDigest.getInstance("SHA-512");
              } catch (NoSuchAlgorithmException e) {
                  throw new RuntimeException("Unable to create message digest", e);
              return md.digest(message);


      Can I get jboss to work with the bytea column without changing the web app.


      Or do I have to change that column from bytea to varchar ?

      Or I can probably encode the digest to hex and store that hex in the database.