CAS实战のclient自定义过滤器

  我们在配置cas client肯定写过如下代码:

 <filter>  
        <filter-name>CASFilter</filter-name>  
        <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
        <filter-class>com.founder.ec.sso.filter.CASFilter</filter-class>
        <init-param>  
            <param-name>casServerLoginUrl</param-name>  
            <param-value>http://localhost:8082/cas/login</param-value>
        </init-param>  
        <init-param>  
            <param-name>serverName</param-name>  
            <param-value>http://localhost:8008/</param-value>
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>CASFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>

  在自定义过滤器的时候,只需要将默认的CASFilter对应的类路径改为自定义的过滤器类。

  CASFilter必须继承AbstractCasFilter,覆盖里面除isRequestUrlExcluded外的所有方法,另重写isRequestUrlExcluded方法。

 private boolean isRequestUrlExcluded(final HttpServletRequest request,final HttpServletResponse response) {
        boolean flag = false;
        String pathInfo = "";
        String servletPath = request.getServletPath();
        if (request.getPathInfo()!=null) pathInfo = request.getPathInfo();
        if (
                servletPath.equals("/testSend.jsp") ||
                pathInfo.equals("/ds/getDataXMLInStr") ||
                
           ){
            flag = true;
        }else if(servletPath.indexOf("login.jsp")>-1){
            flag = false;
      }
        return flag;
    }

  将需要放行的请求置为flag为true的条件中即可。

转载于:https://www.cnblogs.com/tomcatx/p/4585062.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值