版权声明:转载请附链接 https://blog.csdn.net/qq_23536449/article/details/89915991
自定义CustomAuthenticationFilter继承自AbstractCasFilter拷贝org.jasig.cas.client.authentication.AuthenticationFilter中的全部代码,修改isRequestUrlExcluded如下
private boolean isRequestUrlExcluded(HttpServletRequest request) {
String serviceUrl = request.getRequestURL().toString();
String queryStr = request.getQueryString();
if(queryStr != null && queryStr.trim().length()>0){
serviceUrl += "?" + queryStr.trim();
}
if(serviceUrl != null){
if(serviceUrl.endsWith("?wsdl")){
return true;
}
if(serviceUrl.indexOf("?") != -1){
serviceUrl = serviceUrl.substring(0,serviceUrl.indexOf("?"));
}
serviceUrl = serviceUrl.replace("\\", "/");
if(serviceUrl.endsWith("/")){
serviceUrl = serviceUrl.substring(0,serviceUrl.length()-1);
if(serviceUrl.endsWith("/")){
serviceUrl = serviceUrl.substring(0,serviceUrl.length()-1);
}
}
if(serviceUrl.endsWith("/webservice")
|| serviceUrl.endsWith("/rs")
|| serviceUrl.contains("/webservice/common/")
|| serviceUrl.contains("/rs/common/")
|| serviceUrl.contains("/log/log.txt")
|| serviceUrl.endsWith("/checkAppUpdate")
|| serviceUrl.endsWith(".js")
|| serviceUrl.endsWith(".css")
|| serviceUrl.endsWith(".html")
|| serviceUrl.endsWith("/serverUrl")
|| serviceUrl.contains("/swagger/")
|| serviceUrl.contains("/api-docs")
|| serviceUrl.contains("/swagger-resources")
|| serviceUrl.contains("/configuration/ui")){
return true;
}
}
return false;
}
替换Web.xml中的AuthenticationFilter为CustomAuthenticationFilter即可