CAS单点登录https协议修改成http协议

最近在研究CAS单点登录,因为https被浏览器的不信任问题,影响登录。故将https协议修改成http协议。现将修改步骤记录如下:

CAS服务端修改:

1、修改 cas\WEB-INF\spring-configuration目录下的ticketGrantingTicketCookieGenerator.xml

<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
		p:cookieSecure="true"
		p:cookieMaxAge="-1"
		p:cookieName="CASTGC"
		p:cookiePath="/cas" />

把cookieSecure属性修改为false。(默认true是用的http是协议)。

2、修改deployerConfigContext.xml 

<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
					p:httpClient-ref="httpClient" />

添加p:requireSecure="false" 属性。

3、修改部署CAS服务端的tomcat容器的server.xml
注释掉配置https协议添加的如下代码:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
			   keystoreFile="D:/keys/smallkey"
			   keystorePass="111111"/>

CAS客服端修改

下载casclient的源码cas-client-3.1.6-SRC.zip,解压。

1、修改edu.yale.its.tp.cas.client.filter.edu.yale.its.tp.cas.client.filter 包下的CASFilter.java

if (casServiceUrl != null){
            if (! (casServiceUrl.startsWith("https://")|| (casServiceUrl.startsWith("http://") ))){
                throw new ServletException("service URL must start with http:// or https://; its current value is [" + casServiceUrl + "]");
            }
if (! casValidate.startsWith("https://")){
            throw new ServletException("validateUrl must start with https://, its current value is [" + casValidate + "]");

注释掉以上两段代码。

2、修改edu.yale.its.tp.cas.util包下的SecureURL.java

if (!u.getProtocol().equals("https")){
            	// IOException may not be the best exception we could throw here
            	// since the problem is with the URL argument we were passed, not
            	// IO. -awp9
            	log.error("retrieve(" + url + ") on an illegal URL since protocol was not https.");
							throw new IOException("only 'https' URLs are valid for this method");
            }

注释以上一段代码。

重新编译以上两个类为.class文件,打包 casclient的源码为.jar。替换掉客服端的casclient.jar

3、修改客服端项目的web.xml中的casServerLoginUrl属性为http://xxx:xx/cas/login

重启服务,大功告成!



 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值