我的代码地址:https://gitee.com/mac_paas/cas-server-webapp-4.0.7
1、首先说为什么要使用这个版本
其一、5.0以后的版本要使用JDK8; 其二、4.2.x开始是gradle构建,不太熟; 其三、4.1.x和4.2.x启动后360浏览器急速和兼容模式登录状态不共享(原因不知,未深究); 其四、4.0.x及以下版本我熟悉,版本越高变化越大;
2、下载cas-server-webapp-4.0.7
https://github.com/apereo/cas/releases/tag/v4.0.7
下载源码:并拿出cas-server-webapp
3、项目导入IDEA
3.1、POM文件修改
<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><configuration><warName>cas</warName><webResources><resource><directory>${basedir}/src/main/webapp/WEB-INF</directory><filtering>true</filtering><targetPath>WEB-INF</targetPath><includes><include>**/web.xml</include></includes></resource></webResources></configuration></plugin><!--增加跳过代码检查,或者添加checkstyle文件--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-checkstyle-plugin</artifactId><configuration><skip>true</skip></configuration></plugin></plugins></build><!--删除下面配置--><!--<properties><cs.dir>${project.parent.basedir}</cs.dir></properties>-->
3.2、添加licensing文件
WHY?不添加打包报错
Failed to execute goal com.mycila.maven-license-plugin:maven-license-plugin:1.9.0:check (default) on project cas-server-webapp: Resource E:\IDEAWork\test\hxyFrame\frame-casServer/src/licensing/header.txt not found in file system, classpath or URL: unknown protocol: e -> [Help 1]
获取方式自行百度,或从我分享的代码获取
3.3、中文修改
cas-servlet.xml中设置
<!--设置默认语言为中文 -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" p:defaultLocale="zh_CN" />
3.4、修改支持HTTP
修改:deployerConfigContext.xml
< bean class = "org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" p:httpClient-ref = "httpClient" />
增加参数 p:requireSecure=”false” ,是否需要安全验证,即 HTTPS , false 为不采用 如下:
< bean class = "org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" p:httpClient-ref = "httpClient" p:requireSecure= "false" />
修改:ticketGrantingTicketCookieGenerator.xml
修改 p:cookieSecure=”true” 为 p:cookieSecure=” false “, 即不需要安全 cookie 如下部分:
< bean id = "ticketGrantingTicketCookieGenerator" class = "org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure = "false"
p:cookieMaxAge = "-1"
p:cookieName = "CASTGC"
p:cookiePath = "/cas" />
修改:warnCookieGenerator.xml
修改 p:cookieSecure=”true” 为 p:cookieSecure=” false “,即不需要安全 cookie 结果如下:
< bean id = "warnCookieGenerator" class = "org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure = "false"
p:cookieMaxAge = "-1"
p:cookieName = "CASPRIVACY"
p:cookiePath = "/cas" />
4、项目启动
项目默认密码
用户名:casuser 密码:Mellon
配置路径(deployerConfigContext.xml)
<bean id="primaryAuthenticationHandler"
class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">
<property name="users">
<map>
<entry key="casuser" value="Mellon"/>
</map>
</property>
</bean>
访问地址及登录效果



