- 创建cas schema
- 创建表app_user
CREATE TABLE `app_user` (
`username` varchar(30) NOT NULL DEFAULT '',
`password` varchar(45) NOT NULL DEFAULT '',
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; - 插入用户数据
INSERT INTO `cas`.`app_user` (username,password) VALUES ('test','test123'); - 编辑CAS Server 的deployerConfigContext.xml文件
注释掉
<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
改为<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="sql" value="select password from app_user where username=?" />
<property name="dataSource" ref="dataSource" />
</bean>
另外增加 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/cas?useUnicode=true&characterEncoding=utf-8" />
<property name="username" value="user" />
<property name="password" value="pwd" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="defaultAutoCommit" value="true" />
<property name="removeAbandoned" value="true" />
<property name="removeAbandonedTimeout" value="60" />
</bean> - 复制几个jar到lib中
commons-dbcp.jar
commons-pool-1.4.jar
spring-jdbc-2.5.6.jar
commons-collections-3.2.jar