将cas 单点登录协议由https改为http

上传人:第*** 文档编号:31133086 上传时间:2018-02-05 格式:DOC 页数:4 大小:69.50KB
返回 下载 相关 举报
将cas 单点登录协议由https改为http_第1页
第1页 / 共4页
将cas 单点登录协议由https改为http_第2页
第2页 / 共4页
将cas 单点登录协议由https改为http_第3页
第3页 / 共4页
将cas 单点登录协议由https改为http_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《将cas 单点登录协议由https改为http》由会员分享,可在线阅读,更多相关《将cas 单点登录协议由https改为http(4页珍藏版)》请在金锄头文库上搜索。

1、将 CAS 单点登录协议由 https 改为 http近期公司的一个单点登录框架移交到我手上维护, 之前采用的是 https,服务器的配置比较麻烦,就想换成 http来访问,这样服务器端的配置和维护就简单多啦!CAS Server: cas-server-core-3.3.2.jar cas-client-core-3.1.3.jarCAS Client: casclient-2.1.0.jar 下面是我的改进的步骤:1.首先是需要在 CAS 服务器配置是 CAS 服务器端支持 http 协议方式主要改进一下配置文件:ticketGrantingTicketCookieGenerator.xm

2、l 配置文件:html view plaincopyprint?1. 将这个地方的配置改为下面的配置:html view plaincopyprint?1. warnCookieGenerator.xml 配置文件html view plaincopyprint?1. 将这个地方的配置改为下面的配置:html view plaincopyprint?1. deployerConfigContext.xml 配置文件:html view plaincopyprint?1. 将这个地方的配置文件修改为下面的配置:html view plaincopyprint?1. 完成这些地方的修改后,服务器端

3、就支持了 http 协议的访问了 下面开始客户端的改动看过 CAS 客户端的源码的都知道,在配置过滤器类中,都做了访问协议的判断 如下代码:html view plaincopyprint?1. if (casServiceUrl != null) 2. if (! (casServiceUrl.startsWith(https:/)| (casServiceUrl.startsWith(http:/) ) 3. throw new ServletException(service URL must start with http:/ or https:/; its current value

4、 is + casServiceUrl + ); 4. 5. 所以首先我们要做的 是需要将 casclient.jar 的源码找到,将上面类似的这种协议判断屏蔽掉。具体在一下 2 个类里面:第一个是:CASFilter 这个类里面中的 init()方法中,https 的判断屏蔽后如下:html view plaincopyprint?1. if (casGateway & Boolean.valueOf(casRenew).booleanValue() 2. throw new ServletException(gateway and renew cannot both be true in

5、filter configuration); 3. 4. if (casServerName != null & casServiceUrl != null) 5. throw new ServletException(serverName and serviceUrl cannot both be set: chooseone.); 6. 7. if (casServerName = null & casServiceUrl = null) 8. throw new ServletException(one of serverName or serviceUrl must be set.);

6、 9. 10. /* if (casServiceUrl != null) 11. if (! (casServiceUrl.startsWith(https:/)| (casServiceUrl.startsWith(http:/) ) 12. throw new ServletException(service URL must start with http:/ or https:/;its current value is + casServiceUrl + ); 13. 14. */ 15. 16. if (casValidate = null) 17. throw new Serv

7、letException(validateUrl parameter must be set.); 18. 19. /* if (! casValidate.startsWith(https:/) 20. throw new ServletException(validateUrl must start with https:/, its current value is + casValidate + ); 21. 22. */ 23. if (casAuthorizedProxy != null) 24. 25. / parse and remember authorized proxie

8、s 26. StringTokenizer casProxies = 27. new StringTokenizer(casAuthorizedProxy); 28. while (casProxies.hasMoreTokens() 29. String anAuthorizedProxy = casProxies.nextToken(); 30. /* if (!anAuthorizedProxy.startsWith(https:/) 31. throw new ServletException(CASFilter initialization parameter for authori

9、zed proxies + 32. must be a whitespace delimited list of authorized proxies. +33. Authorized proxies must be secure (https) addresses. This one wasnt: + anAuthorizedProxy + ); 34. */ 35. this.authorizedProxies.add(anAuthorizedProxy); 36. 37. 第二个是:edu.yale.its.tp.cas.util.SecureURL 这个类里面的 retrieve 方法

10、中,屏蔽后如下:html view plaincopyprint?1. URL u = new URL(url); 2. /*if (!u.getProtocol().equals(https) 3. / IOException may not be the best exception we could throw here 4. / since the problem is with the URL argument we were passed, not 5. / IO. -awp9 6. log.error(retrieve( + url + ) on an illegal URL s

11、ince protocol was nothttps.); 7. throw new IOException(only https URLs are valid for this method); 8. */ 9. 10. URLConnection uuc = u.openConnection(); 重新打包后将 casclient.jar 更新到我们的程序第三方 lib 包中。剩下的就是修改我们程序的 web.xml 中关于 cas 的配置,把 https 的配置全部修改为 http,记得端口号改为你CAS 服务器的访问端口号,而不再是 https 的访问端口号。另外要说明的是:在网上看到有鞋童说 退出时还是必须使用 https,于是我就在我本地尝试了下,我退出时并没有使用 https,退出没有问题。如果退出仍然需要使用 https,那么我们把访问改成 http,就没有任何意义了,服务器仍然需要进行 https 的配置。下面提供我修改好的 casclient.jar 的文件,只是把 https 的协议判断屏蔽了,没有做其他的修改。如果需要源码的,可以在网上找找,或者直接问我要都可以。以上有不正确的,还望斧正。casclient-2.1.0.jar

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号