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.
98 lines
3.1 KiB
98 lines
3.1 KiB
2 years ago
|
package com.fr.plugin.xx.zyjn.decode;
|
||
|
|
||
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider;
|
||
|
import com.fr.intelli.record.Focus;
|
||
|
import com.fr.intelli.record.Original;
|
||
|
import com.fr.log.FineLoggerFactory;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.plugin.xx.zyjn.decode.decode.DecodeFilter;
|
||
|
import com.fr.plugin.transform.FunctionRecorder;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
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
|
||
|
*/
|
||
|
@FunctionRecorder
|
||
|
@Authorize(callSignKey = PluginConstants.PLUGIN_ID)
|
||
|
@EnableMetrics
|
||
|
public class GlobalFilter extends AbstractGlobalRequestFilterProvider {
|
||
|
@Override
|
||
|
public String filterName() {
|
||
|
return "zdgl";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@Focus(id = PluginConstants.PLUGIN_ID, text = PluginConstants.PLUGIN_NAME, source = Original.PLUGIN)
|
||
|
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;
|
||
|
}
|
||
|
/*if (isEncode(req)) {
|
||
|
new EncodeFilter().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;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
private boolean isEncode(HttpServletRequest req) {
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
}
|