1.修改cas server的deployerConfigContext.xml
<bean />
</bean>
2.配置cas client的 web.xml。
<filter>
<filter-name>CASFilter</filter-name>
<filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
<param-value>http://zhangyg-pc:8443/cas/login</param-value>
</init-param><!--这里是服务端的主机名-->
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
<param-value>http://zhangyg-pc:8443/cas/proxyValidate</param-value>
</init-param><!--这里是服务端的主机名,而且必须是-->
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
<param-value>192.168.10.98:8080</param-value><!--client:port就是需要CAS需要拦截的地址和端口,一般就是Client端的IP和port-->
</init-param>
</filter>
<filter-mapping>
<filter-name>CASFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.需要注意的是我们在这里去掉了https的支持。
主要修改了
1.edu.yale.its.tp.cas.util.SecureURL
2.edu.yale.its.tp.cas.client.filter.CASFilter
中的https验证。
如:
// 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 + "]");
// }
// }
4.系统注销
由于登录后,是否登录是通过session验证的。所以注销的时候除了调用 cas的http://serverip/cas/logout,同时需要对删除session。
需要写一个 logout页面。代码如下:
<%
session.invalidate();
response.sendRedirect("http://serverip:8080/cas/logout?service=http://clientip:8080/casclient/index.jsp");
%>