CAS4.1.4数据库配置

         
            
             < bean id = "dataSource"   class = "org.springframework.jdbc.datasource.DriverManagerDataSource" >  
                < property name = "driverClassName" value = "com.mysql.jdbc.Driver" />  
                < property name = "url"  
                    value = " jdbc:mysql://127.0.0.1:3306/sprv" />  
                < property name = "username" value = "root" />  
                < property name = "password" value = "****"  />  
             bean >  
             
            
             < bean id = "primaryAuthenticationHandler" class = "org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler" >
                < property name = "dataSource" ref = "dataSource" />
                < property name = "sql" value = "select password from usertable where username=?" />    
                
                < property name = "passwordEncoder" ref = "passwordEncoder" />
             bean >  
             
            
             < bean id = "passwordEncoder" class = "com.neusoft.cas.NeuPasswordEncoder" />


package com.neusoft.cas;
import org.jasig.cas.authentication.handler.PasswordEncoder;
/**
 *
* @ClassName : NeuPasswordEncoder
* @Description : CAS密码加密方法
* @author 
* @date 
*
 */
public class NeuPasswordEncoder implements PasswordEncoder{
    /**
     * 将输入密码进行加密处理并返回以和数据库密码进行验证
     */
    @Override
    public String encode(String passwd ){
        // 去掉加密过程,直接返回原密码
        // ShaPasswordEncoder encoder=new ShaPasswordEncoder();
        // encoder.setEncodeHashAsBase64(true);
        // return encoder.encodePassword(args,null);
        return passwd ;
    }
}

遇到的一些其他问题:

Q:配置数据源的时候提示“啥啥啥必须以分号结尾”

A:url中的"&"符号需写成"&"


Q:连接数据库时提示timezone错误

A:修改mysql时区:mysql> set global time_zone="+8:00"

你可能感兴趣的:(CAS)