终于解决l了,可结贴。
对于CAS认证,其实有两种方式,第一种是斑竹在上面提供的tomcat搭建cas服务器与客户端的方法,另一种是webshphere搭建的CAS服务器。
第一种,需要生成证书,具体配制见楼上斑竹转发的帖子。
第二种,不需要证书,客户端的认证模式首先在服务端登记就可以。在搭建的时候需要修改/runtime/UIServer/WEB-INF/web.xml,添加
<filter>
<filter-name>CAS Filter</filter-name>
<filter-class>***.CASFilter</filter-class>
<init-param>
<param-name>***.loginUrl</param-name>
<param-value>http://***/login</param-value>
</init-param>
<init-param>
<param-name>***.validateUrl</param-name>
<param-value>http://***Validate</param-value>
</init-param>
<init-param>
<param-name>***.serverName</param-name>
<param-value>127.0.0.1</param-value>
</init-param>
<init-param>
<param-name>***.needSSOLogout</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>excludedPages</param-name>
<param-value>/UI2/portal/mobile/index.w</param-value>
</init-param>
</filter>
<filter-name>CAS Filter</filter-name>
<url-pattern>/UI2/portal/pc/index.w</url-pattern>
</filter-mapping>
<filter>
<filter-name>NTLoginFilter</filter-name>
<filter-class>com.justep.filter.NTLoginFilter</filter-class>
<init-param>
<param-name>/UI/portal/login.w</param-name>
<param-value>/portal/index.w</param-value>
</init-param>
<init-param>
<param-name>/UI/portal2/process/portal/login.w</param-name>
<param-value>/UI/portal2/process/portal/index.w</param-value>
</init-param>
<init-param>
<param-name>/UI2/portal/pc/index.w</param-name>
<param-value>/UI2/portal/pc/index.w</param-value>
</init-param>
<init-param>
<param-name>/UI2/portal/mobile/index.w</param-name>
<param-value>/UI2/portal/mobile/index.w</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>NTLoginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
另需要加载x5-client.jar到/runtime/UIServer/WEB-INF/lib
对于需要过滤的页面,比如过滤手机登录页面/UI2/portal/mobile/index.w,则将其加入excludedPages中,这时需要修改CAS客户端接口的class文件。具体修改方法可百度一下,大概步骤就是
加入:
private StringexcludedPages; private String[]excludedPageArray;
public void init(FilterConfig config) throws ServletException {//加入 excludedPages =config.getInitParameter("excludedPages"); if(StringUtils.isNotEmpty(excludedPages)) { excludedPageArray =excludedPages.split(","); }
public void doFilter(ServletRequestrequest, ServletResponse response, FilterChain fc) throws ServletException, IOException { booleanisExcludedPage = false; for (String page : excludedPageArray){//判断是否在过滤url之外 if(((HttpServletRequest)request).getServletPath().equals(page)){ isExcludedPage = true; break; } } if (isExcludedPage) {//在过滤url之外 fc.doFilter(request, response); } else { ……}
|