zoukankan      html  css  js  c++  java
  • 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的条件中即可。

  • 相关阅读:
    福大软工 · 第八次作业(课堂实战)- 项目UML设计(团队)
    第六次作业
    福大软工1816 · 第五次作业
    福大软工1816 · 第四次作业
    福大软工1816 · 第三次作业
    福大软工1816 · 第二次作业
    软工实践-团队现场编程
    qwe
    软工冲刺-Alpha 冲刺 (3/10)
    软工时间-Alpha 冲刺 (2/10)
  • 原文地址:https://www.cnblogs.com/tomcatx/p/4585062.html
Copyright © 2011-2022 走看看