一、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即可