CAS Authentication using MYSQL database. 'principal' cannot be null

时间:2015-06-26 10:29:11

标签: java mysql spring spring-mvc cas

As a part of learning Jasig CAS I was trying to change the authentication with database. But it is not working as expected. The authentication failed with following Log

2015-06-26 20:19:09 DEBUG JdbcTemplate:247 - Executing prepared SQL query

2015-06-26 20:19:09 DEBUG JdbcTemplate:247 - Executing prepared SQL statement [select password from users where username=? and active=1]

2015-06-26 20:19:09 DEBUG DataSourceUtils:247 - Fetching JDBC Connection from DataSource

2015-06-26 20:19:09 DEBUG BasicResourcePool:1644 - trace com.mchange.v2.resourcepool.BasicResourcePool@41e38895 [managed: 6, unused: 5, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@27f37294)

2015-06-26 20:19:09 DEBUG DataSourceUtils:247 - Returning JDBC Connection to DataSource

2015-06-26 20:19:09 DEBUG BasicResourcePool:1644 - trace com.mchange.v2.resourcepool.BasicResourcePool@41e38895 [managed: 6, unused: 5, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@27f37294)

2015-06-26 20:19:09 DEBUG TicketOrCredentialPrincipalResolver:202 - Resolving argument [UsernamePasswordCredential] for audit
2015-06-26 20:19:09 INFO Slf4jLoggingAuditTrailManager:306 - Audit trail record BEGIN


WHO: admin+password
WHAT: 'principal' cannot be null.
Check the correctness of @Audit annotation at the following audit point: execution(public abstract transient org.jasig.cas.authentication.Authentication
org.jasig.cas.authentication.AuthenticationManager.authenticate(org.jasig.cas.authentication.Credential[]))
ACTION: TICKET_GRANTING_TICKET_NOT_CREATED
APPLICATION: CAS
WHEN: Fri Jun 26 15:24:13 IST 2015
CLIENT IP ADDRESS: 127.0.0.1
SERVER IP ADDRESS: 127.0.0.1

deployerConfigContext.xml has the following information

<bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager">

        <constructor-arg>
            <list>
            <ref bean="dbAuthHandler" />
         </list>
        </constructor-arg>

        <property name="authenticationPolicy">
            <bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" />
        </property>
    </bean>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        p:driverClass="${database.driverClass}" p:jdbcUrl="${database.url}"
        p:user="${database.user}" p:password="${database.password}"
        p:initialPoolSize="${database.pool.minSize}" p:minPoolSize="${database.pool.minSize}"
        p:maxPoolSize="${database.pool.maxSize}"
        p:maxIdleTimeExcessConnections="${database.pool.maxIdleTime}"
        p:checkoutTimeout="${database.pool.maxWait}" p:acquireIncrement="${database.pool.acquireIncrement}"
        p:acquireRetryAttempts="${database.pool.acquireRetryAttempts}"
        p:acquireRetryDelay="${database.pool.acquireRetryDelay}"
        p:idleConnectionTestPeriod="${database.pool.idleConnectionTestPeriod}"
        p:preferredTestQuery="${database.pool.connectionHealthQuery}" />

    <bean id="passwordEncoder"
          class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
          c:encodingAlgorithm="MD5"
          p:characterEncoding="UTF-8" />

    <bean id="dbAuthHandler"
      class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler"
      p:dataSource-ref="dataSource"
      p:passwordEncoder-ref="passwordEncoder"
      p:sql="select password from users where username=? and active=1" />

The credentials are validated [ie. No "Invalid credentials" message]

0 个答案:

没有答案