You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
3.0 KiB
94 lines
3.0 KiB
package com.hzdatalink.gsdes.filter; |
|
|
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; |
|
import com.fr.log.FineLoggerFactory; |
|
import com.fr.plugin.context.PluginContexts; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.FilterChain; |
|
import javax.servlet.ServletException; |
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.io.IOException; |
|
|
|
/** |
|
* @author xx |
|
* @date 2020/11/20 |
|
*/ |
|
public class GlobalFilter extends AbstractGlobalRequestFilterProvider { |
|
@Override |
|
public String filterName() { |
|
return "gsdes"; |
|
} |
|
|
|
@Override |
|
public String[] urlPatterns() { |
|
if (PluginContexts.currentContext().isAvailable()) { |
|
return new String[]{ |
|
"/*" |
|
}; |
|
} else { |
|
return new String[]{"/neverbeused"}; |
|
} |
|
} |
|
|
|
@Override |
|
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) { |
|
if (isDecode(req)) { |
|
new DecodeFilter().doFilter(req, res, filterChain); |
|
return; |
|
} |
|
|
|
try { |
|
filterChain.doFilter(req, res); |
|
} catch (IOException e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
} catch (ServletException e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage()); |
|
} |
|
} |
|
|
|
private boolean isDecode(HttpServletRequest req) { |
|
if (req.getRequestURI().endsWith("attach/upload")) { |
|
return true; |
|
} |
|
if (req.getRequestURI().endsWith("/dataset/upload")) { |
|
return true; |
|
} |
|
String op = WebUtils.getHTTPRequestParameter(req, "op"); |
|
String cmd = WebUtils.getHTTPRequestParameter(req, "cmd"); |
|
if (StringUtils.equals("fr_attach", op) && StringUtils.equals("ah_upload", cmd)) { |
|
return true; |
|
} |
|
if (StringUtils.equals("fr_write", op) && StringUtils.equals("imp_w_excel_data", cmd)) { |
|
return true; |
|
} |
|
if (StringUtils.equals("fr_mark_excel", op) && StringUtils.equals("cache_excel", cmd)) { |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
private boolean isEncode(HttpServletRequest req) { |
|
if (req.getRequestURI().endsWith("/report/data/export")) { |
|
return true; |
|
} |
|
if (req.getRequestURI().endsWith("/report/data/global/export/pdf")) { |
|
return true; |
|
} |
|
if (req.getRequestURI().endsWith("/report/data/global/export/excel")) { |
|
return true; |
|
} |
|
String op = WebUtils.getHTTPRequestParameter(req, "op"); |
|
String cmd = WebUtils.getHTTPRequestParameter(req, "cmd"); |
|
if (StringUtils.equals("fr_attach", op) && StringUtils.equals("ah_download", cmd)) { |
|
return true; |
|
} |
|
if (StringUtils.equals("customcommit", op) && StringUtils.equals("downloadfile", cmd)) { |
|
return true; |
|
} |
|
return false; |
|
} |
|
|
|
}
|
|
|