Cas_Server端安装
一、Cas Server版本:3.5.2
二、安装步骤:
1、解压cas-server-3.5.2.zip并部署到tomcat下
2、运行tomcat站点,进入登录页面(默认端口为8080)
3、创建数据库及用户表
a) 创建数据库:sso
b) 创建用户表并初始化用户
1
2
3
4
5
6
7
8
9
10
11
|
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 `app_user` (`username`,` password `) VALUES ( 'test' , '111' ), ( 'user' , '222' ), ( 'tom' , '333' ), ( 'jim' , '000' ); |
4、修改配置文件 deployerConfigContext.xml
a)、注销bean:org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler并用新代码替换
1
2
3
4
5
6
7
8
|
<!-- <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 > |
b)、beans节点下添加bean:dataSource
1
2
3
4
5
6
|
< bean id = "dataSource" class = "org.springframework.jdbc.datasource.DriverManagerDataSource" > < property name = "driverClassName" >< value >com.mysql.jdbc.Driver</ value ></ property > < property name = "username" >< value >root</ value ></ property > < property name = "password" >< value >123456</ value ></ property > </ bean > |
5、重启tomcat
cd /bin ./shutdown.sh ./startup.sh
6、登录服务器:使用3.b步中插入的
三、可能遇到的问题:
1、登录时提示:Non-Secure-Connection
解决方法:注销相关代码即可
2、账号密码正确但是一直报验证错误:重启tomcat即可