Skip to end of metadata
Go to start of metadata
Table of Contents

New CAS documentation site

CAS documentation has moved over to, starting with CAS version 4.x. The wiki will no longer be maintained. For the most recent version of the documentation, please refer to the aforementioned link.

JDBC Authentication Handler

Including the Handler

In the pom.xml file for your CAS Maven2 WAR Overlay, add the following dependency:


Core Classes

Note that all JDBC AuthenticationHandlers have the requirement for a DataSource. Each handler's section will only list additional properties beyond the DataSource.


This authentication handler attempts to take the provided credentials and open a connection with them.


This authentication handler takes a database query (who's value is a password and one parameter is a username). It will then compare the password from the database with the password provided by the user (after encoding via the PasswordEncoder).


  • sql - The SQL statement, in the following format: "Select password from table where username = ?"
  • passwordEncoder - The PasswordEncoder to use. The default is the PlainTextPasswordEncoder.

The DefaultPasswordEncoder class supports use cases where a message digest function (hash) needs to be applied to the password for comparison with the stored value in the database. This behavior is best security practice and the default on most modern database platforms. The following example demonstrates how to configure DefaultPasswordEncoder for the MD5 hash function.

DefaultPasswordEncoder with MD5
<bean class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"

See the MAC section of for a list of supported message digest functions in the default Sun cryptography provider (JCE).

(note : on cas-3.4.8, I had to change the previous sample with the following :

DefaultPasswordEncoder with MD5 on cas 3.4.8
<bean class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder" p:characterEncoding="UTF-8" >
    <constructor-arg index="0" value="MD5" />



Given a table, username field and password field, this will query a database table with the provided encryption technique to see if the user exists.


  • fieldUser - the name of the field containing the username
  • fieldPassword - the name of the field containing the password
  • tableUsers - the name of the table containing the users


  • No labels