org.jasig.cas.authentication.handler.DefaultPasswordEncoder sha1 and md5 not working plaintext is fine

599 views Asked by At

I am trying to configure cas to use an encoded password from my database.

When I configure as plain text it works fine.

When I configure to encode as MD5 or SHA1 it always fails to authenticate.

My config looks like this

<bean class="org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler">
  <property name="tableUsers">
    <value>uh_ors_test_users</value>
  </property>
  <property name="fieldUser">
    <value>username</value>
  </property>
  <property name="fieldPassword">
    <value>password</value>
  </property>
  <property name="passwordEncoder">
    <bean class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
      <constructor-arg value="MD5" />
    </bean>
  </property>
  <property name="dataSource" ref="dataSource" />
</bean>

Without passwordEncoder it works fine with plain text passwords.

I am encoding my passwords by doing the following. echo "plain text password" | md5sum echo "plain text password" | sha1sum

And putting the output from these commands into my database in the password field.

for example for user="bob" with password="bobs_password" echo bobs_password | md5sum 4ee4c4a91f34ce62335942ca73b15b5c -

So database user table contains contains user:bob password:4ee4c4a91f34ce62335942ca73b15b5c for my "MD5" testing

to test SHA1 I used echo bobs_password | sha1sum d62cfc513413784cb3b9e558abecf56069528681 - So database user table contains contains user:bob password:d62cfc513413784cb3b9e558abecf56069528681 for my "SHA1" testing

I can't tell if I am encoding wrong, if my config is wrong or if the code is doing something different then I expect.

Does anyone see an issue with what I am doing ? Is it possible to enable logging to see the post encoded password to compare ? I have log4j logging set to "ALL" and I can see the getUser and getPassword values but they are as I typed not post encoded so I can't tell what the encoded value looks like.

1

There are 1 answers

0
Ronald Gouldner Jr On

I found my mistake. echo adds a newline needed to encode with echo -n "password" | md5sum