cas 服务器端的配置

.修改cas/webapp/WEB-INF/deployerConfigContext.xml
加入以下定义:

定义1:

<!-- 数据源定义 -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>
<!--
   passwordEncoder 使用Md5算法加密
-->
<bean id="passwordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder" autowire="byName">
<constructor-arg value="MD5"/>
</bean>

定义2:

<!-- 数据源定义 -->

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
</bean>
<!--
   passwordEncoder 使用Md5算法加密
-->
<bean id="passwordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder" autowire="byName">
<constructor-arg value="MD5"/>
</bean>
推荐用定义2,定义1似乎有时候会报io错误。

2.屏蔽原有验证方法:

Xml代码

<!--
<bean
class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
-->

3.加入通过访问数据库进行验证的handler:
Xml代码
<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="sql" value="select password from CORE_USERS where logid=?" />
<property name="passwordEncoder" ref="passwordEncoder"/>
<property name="dataSource" ref="dataSource" />
</bean>

4.修改cas\webapp\WEB-INF\cas.properties,定义数据库连接资源
For Oracle:
db.driver=oracle.jdbc.driver.OracleDriver
db.url=jdbc\:oracle\:thin\:@192.168.1.1\:1521\:xxxx
db.username=xxxx
db.password=xxxx
For Mysql:
db.driver=com.mysql.jdbc.Driverdb.url=jdbc:mysql://127.0.0.1:3306/passport_dbdb.username=root
db.password=
5.从http://commons.apache.org/下载:commons-pool-1.3.zip 和 commons-dbcp-1.2.2.zip 解压后把里面的Jar文件放入cas/webapp/WEB-INF/lib中(如果用定义1的话)

附:数据库建库语句:
# Host: localhost Database: passport_db# ------------------------------------------------------# Server version 5.0.27-community-nt
DROP DATABASE IF EXISTS `passport_db`;CREATE DATABASE `passport_db` /*!40100 DEFAULT CHARACTER SET utf8 */;USE `passport_db`;
## Table structure for table passport#
CREATE TABLE `passport` ( `id` int(20) NOT NULL auto_increment, `account` varchar(255) NOT NULL default 'guest', `password` varchar(255) default NULL, `role` varchar(16) NOT NULL default 'user', PRIMARY KEY (`id`), UNIQUE KEY `account` (`account`)) DEFAULT CHARSET=utf8;

你可能感兴趣的:(oracle,mysql,算法,Web,jdbc)