CAS Server 40二次开发说明文档.docx

上传人:b****5 文档编号:6066970 上传时间:2023-01-03 格式:DOCX 页数:41 大小:702.76KB
下载 相关 举报
CAS Server 40二次开发说明文档.docx_第1页
第1页 / 共41页
CAS Server 40二次开发说明文档.docx_第2页
第2页 / 共41页
CAS Server 40二次开发说明文档.docx_第3页
第3页 / 共41页
CAS Server 40二次开发说明文档.docx_第4页
第4页 / 共41页
CAS Server 40二次开发说明文档.docx_第5页
第5页 / 共41页
点击查看更多>>
下载资源
资源描述

CAS Server 40二次开发说明文档.docx

《CAS Server 40二次开发说明文档.docx》由会员分享,可在线阅读,更多相关《CAS Server 40二次开发说明文档.docx(41页珍藏版)》请在冰豆网上搜索。

CAS Server 40二次开发说明文档.docx

CASServer40二次开发说明文档

CASServer4.0二次开发说明文档

1.环境搭建2

2.拓展后最终目录结构7

3.修改CASServer支持HTTP协议8

4.修改CAS服务器端登录认证方式为数据库认证9

4.1.在pom中添加如下的依赖9

4.2.创建ValidUserQueryDBAuthenticationHandler10

4.3.修改deployerConfigContext.xml10

5.登录连续错误三次以上出现验证码校验11

5.1.添加kaptcha验证码依赖库11

5.2.配置web.xml12

5.3.UsernamePasswordCaptchaCredentia12

5.4.修改cas登录页,添加验证码字段12

5.5.添加验证码校验13

5.6.自定义异常处理Handler统计错误次数16

5.7.修改配置cas-servlet.xml16

5.8.修改配置login-webflow.xml17

6.CAS服务器端返回多个属性字段17

6.1.创建MultipleAttributeUserDao模拟用户自定义属性18

6.2.修改deployerConfigContext.xml18

6.3.修改casServiceValidationSuccess.jsp18

7.CASServer集群部署时Ticket同步21

7.1.添加redis依赖21

7.2.创建RedisTicketRegistry22

7.3.创建TicketRedisTemplate22

7.4.修改ticketRegistry.xml23

7.5.修改web.xml24

8.CASServer登录页定制24

8.1.拷贝资源文件24

8.2.修改casLoginView.jsp25

8.3.基于theme方式25

9.修改CASServer为移动端设备提供REST登录服务25

9.1.添加依赖26

9.2.修改webx.xml27

9.3.请求票据授权27

9.4.请求服务授权28

9.5.JavaClient测试29

 

在生产环境中,官方提供的CASServer功能远远不能满足我们的需求。

这个时候我们就需要基于源码进行二次开发,以满足我们的线上使用。

这里主要是基于CAS服务器端。

本文档主要描述目前在CASServer4.0版本基础上做了哪些改进。

1.环境搭建

这里为了方便起见采用mavenoverlays特性(通路径下的同名文件会使用最新的资源文件替换已有war目录中下的资源文件)搭建,因此这里不用将cas-server-webapp模块的所有源码导入到工程里,只需将需要修改的文件按源码里面的目录层次结构排列,最终编译构建打包时会自动添加新特性或替换原有文件,这是一件很方便的事,修改和添加了哪些文件一目了然。

以下列出了本文档所涉及到所有拓展功能及最终编译打包所需的maven依赖。

pom.xml

//maven.apache.org/POM/4.0.0"xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="http:

//maven.apache.org/POM/4.0.0http:

//maven.apache.org/maven-v4_0_0.xsd">

4.0.0

net.aimeizi

cas-server-webapp

4.0.0

war

JasigCASWebApplication

JasigCASServerWebApplication

--文件拷贝时的编码-->

UTF-8

UTF-8

--编译时的编码-->

UTF-8

org.jasig.cas

cas-server-webapp

4.0.0

war

runtime

org.jasig.cas

cas-server-core

4.0.0

test-jar

org.jasig.cas

cas-server-webapp-support

4.0.0

compile

*

*

javax.servlet

servlet-api

2.5

compile

javax.servlet

jstl

1.1.2

jar

runtime

taglibs

standard

1.1.2

jar

runtime

mysql

mysql-connector-java

5.1.38

com.alibaba

druid

1.0.18

org.jasig.cas

cas-server-support-jdbc

4.0.0

--casserverrestlet-->

org.jasig.cas

cas-server-integration-restlet

4.0.0

org.springframework

spring-webmvc

org.springframework

spring-context

org.springframework

spring-core

org.restlet.jee

org.restlet

2.1.0

org.restlet.jee

org.restlet.ext.spring

2.1.0

org.springframework

spring-asm

org.springframework

spring-web

org.springframework

spring-expression

org.restlet.jee

org.restlet.ext.servlet

2.1.0

org.restlet.jee

org.restlet.ext.slf4j

2.1.0

--casserverrestlet-->

--redis-->

org.springframework.data

spring-data-redis

1.7.1.RELEASE

*

*

mons

commons-pool2

2.4.2

redis.clients

jedis

2.8.1

com.google.code.kaptcha

kaptcha

2.3.2

--system-->

--${basedir}/lib/kaptcha-2.3.2.jar-->

mons

commons-lang3

3.4

--shirocrypto-->

org.apache.shiro

shiro-core

1.2.2

commons-httpclient

commons-httpclient

3.1

cas

2.拓展后最终目录结构

3.修改CASServer支持HTTP协议

修改src\main\webapp\WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml文件

xmlversion="1.0"encoding="UTF-8"?

>

//www.springframework.org/schema/beans"

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xmlns:

p="http:

//www.springframework.org/schema/p"

xsi:

schemaLocation="http:

//www.springframework.org/schema/beanshttp:

//www.springframework.org/schema/beans/spring-beans.xsd">

--p:

cookieSecure="true"表示开启https协议,cookieSecure设置为false关闭https协议-->

p:

cookieSecure="false"

p:

cookieMaxAge="3600"

p:

cookieName="CASTGC"

p:

rememberMeMaxAge="3600"

p:

cookiePath="/cas"/>

修改src\main\webapp\WEB-INF\spring-configuration\warnCookieGenerator.xml文件

xmlversion="1.0"encoding="UTF-8"?

>

//www.springframework.org/schema/beans"

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xmlns:

p="http:

//www.springframework.org/schema/p"

xsi:

schemaLocation="http:

//www.springframework.org/schema/beanshttp:

//www.springframework.org/schema/beans/spring-beans.xsd">

--p:

cookieSecure="true"表示开启https协议,cookieSecure设置为false关闭https协议-->

p:

cookieSecure="false"

p:

cookieMaxAge="-1"

p:

cookieName="CASPRIVACY"

p:

cookiePath="/cas"/>

4.修改CAS服务器端登录认证方式为数据库认证

CasServer默认提供简单用户密码认证即(casuser/Mellon,该部分内容在src\main\webapp\WEB-INF\deployerConfigContext.xml文件中可以看到。

),显然这不能满足我们的线上环境。

在此我们需要修改使其支持基于数据库的用户名密码校验。

要想使用数据库校验,需要为casserver提供相应的jdbc依赖。

4.1.在pom中添加如下的依赖

mysql

mysql-connector-java

5.1.38

com.alibaba

druid

1.0.18

org.jasig.cas

cas-server-support-jdbc

4.0.0

4.2.创建ValidUserQueryDBAuthenticationHandler

在src/main/java目录下创建org.jasig.cas.adaptors.jdbc包,在该包下创建ValidUserQueryDBAuthenticationHandler.java文件。

因内容较多,这里不再列出,具体请查看源码

4.3.修改deployerConfigContext.xml

--数据源-->

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1