您的位置:首页 > 数据库

SSO单点登录 cas_server通过查询数据库验证用户名、密码正确性

2016-08-21 21:18 746 查看

cas_server通过查询数据库验证用户名、密码正确性

jar包准备

1、mysql jdbc驱动:mysql-connector-java-5.1.13-bin.jar

2、spring jdbc : spring-jdbc-3.2.6.RELEASE.jar

3、cas jdbc支持:cas-server-support-jdbc-3.4.11.jar

编辑:WEB-INF\deployerConfigContext.xml,加入数据源:

将下面代码注释掉

<!--
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" /> -->


<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/cas_db</value>
</property>
</bean>
<bean id="proxyAuthenticationHandler" class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="dataSource" />
<property name="sql"
value="select password from t_user where loginName = ?" />
<property  name="passwordEncoder"  ref="MD5PasswordEncoder"/>
</bean>
<bean id="MD5PasswordEncoder" class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
<constructor-arg index="0" value="MD5" />
</bean>


配置tomcat jndi 数据源

<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="100"
maxIdle="50"
maxWait="5000"
minEvictableIdleTimeMillis="1000"
name="jdbc/cas_db"
numTestsPerEvictionRun="3"
password="123456"
testOnBorrow="true"
testOnReturn="true"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="300000"
type="javax.sql.DataSource"
url="jdbc:mysql://127.0.0.1:3306/shiro?useUnicode=true&characterEncoding=UTF-8"
username="root" validationQuery="SELECT 1" />


至此即实现了cas_server通过查询数据库验证用户名、密码正确性
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐