|
|
@@ -1,42 +0,0 @@
|
|
|
-package com.uas.platform.b2c.core.filter;
|
|
|
-
|
|
|
-import com.uas.platform.b2c.common.keyword.service.KeyWordService;
|
|
|
-import com.uas.platform.b2c.core.support.BodyReaderHttpServletRequestWrapper;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-import org.springframework.web.context.support.WebApplicationContextUtils;
|
|
|
-import org.springframework.web.context.support.XmlWebApplicationContext;
|
|
|
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
|
|
-
|
|
|
-import javax.servlet.ServletContext;
|
|
|
-import javax.servlet.ServletRequest;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.Set;
|
|
|
-
|
|
|
-/**
|
|
|
- *
|
|
|
- */
|
|
|
-public class SensitiveWordsInterceptor extends HandlerInterceptorAdapter {
|
|
|
-
|
|
|
- public static Set<String> keyworsSet = null;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private KeyWordService keyWordService;
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
|
- String contentType = request.getContentType();
|
|
|
- String method = request.getMethod();
|
|
|
- // POST请求 或 PUT请求,并且不是附件上传请求
|
|
|
- if(("POST".equals(method) || "PUT".equals(method)) && (StringUtils.isEmpty(contentType) || !contentType.contains("multipart"))){
|
|
|
- if(keyworsSet == null){
|
|
|
- keyworsSet = keyWordService.getAllKeyWordContent();
|
|
|
- }
|
|
|
- // request包装类 改写getParameterValues和getInputStream
|
|
|
- request = new BodyReaderHttpServletRequestWrapper(request);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
-}
|