<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="dataSourceForMySql" ></property>
<property name="sql" value="select password from eauser as u where u.ACCOUNT = ? and u.enabled = 1" ></property>
<property name="passwordEncoder" ref="EDS2PasswordEncoder" ></property>
</bean>
<!--数据验证模式 自定义的加密类,返回值:加密后的字符串-->
<bean id="EDS2PasswordEncoder" class="org.jasig.cas.authentication.handler.SunPasswordEncoder">
</bean>
//必须实现org.jasig.cas.authentication.handler.PasswordEncoder接口 需导入的包是cas-server-core-xxx.jar
public class SunPasswordEncoder implements PasswordEncoder{
@Override
public String encode(String password) {
String end = Tools.encryptBasedDes(password);
return end;
}
}
加密方式:http://blog.csdn.net/s445320/article/details/9897189
我的实际项目改动的地方:
<!-- 设置密码的加密方式,这里使用的是MD5加密 -->
<!--
<bean id="passwordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
c:encodingAlgorithm="MD5"
p:characterEncoding="UTF-8" />
-->
<bean id="passwordEncoder" class="com.java.enDecrypt.EnDecryptPasswordEncoder"/>//自己定义的算法打的jar包
<!-- 通过数据库验证身份,这个得自己去实现 -->
<bean id="primaryAuthenticationHandler"
class="com.distinct.cas.jdbc.QueryDatabaseAuthenticationHandler"
p:dataSource-ref="dataSource"
p:passwordEncoder-ref="passwordEncoder"
p:sql="select password from t_user where userName=?" />
转载:https://blog.csdn.net/s445320/article/details/12218993
还可参考:https://www.cnblogs.com/wangyang108/p/5843923.html