|
|
@@ -0,0 +1,55 @@
|
|
|
+package com.uas.report.controller.filter;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import javax.servlet.Filter;
|
|
|
+import javax.servlet.FilterChain;
|
|
|
+import javax.servlet.FilterConfig;
|
|
|
+import javax.servlet.ServletException;
|
|
|
+import javax.servlet.ServletRequest;
|
|
|
+import javax.servlet.ServletResponse;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.report.core.advice.ExceptionHandlerAdvice;
|
|
|
+import com.uas.report.core.exception.ReportException;
|
|
|
+import com.uas.report.util.IpHelper;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 对文件删除进行过滤
|
|
|
+ *
|
|
|
+ * @author sunyj
|
|
|
+ * @since 2016年12月13日 下午4:46:03
|
|
|
+ */
|
|
|
+public class FileDeleteFilter implements Filter {
|
|
|
+
|
|
|
+ public static final String PARAM_NAME_USERNAME = "userNsame";
|
|
|
+ public static final String PARAM_NAME_PASSWORD = "password";
|
|
|
+
|
|
|
+ private FilterConfig filterConfig;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void init(FilterConfig filterConfig) throws ServletException {
|
|
|
+ this.filterConfig = filterConfig;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
|
|
+ throws IOException, ServletException {
|
|
|
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
|
|
|
+ HttpServletResponse httpResponse = (HttpServletResponse) response;
|
|
|
+ // 局域网内才允许执行
|
|
|
+ if (!IpHelper.isLAN(IpHelper.getIp(httpRequest))) {
|
|
|
+ ExceptionHandlerAdvice.handleError(httpResponse, HttpServletResponse.SC_FORBIDDEN, "没有权限");
|
|
|
+ } else {
|
|
|
+ chain.doFilter(httpRequest, response);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void destroy() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|