Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
shuaje committed Dec 12, 2017
1 parent 1fdaeac commit 23f50e8
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ public class MaliciousRequestInterceptor extends BaseInterceptor {

// 白名单
private List<String> whiteUrls;
private int _size = 0;

public MaliciousRequestInterceptor() {
// 读取文件
String path = MaliciousRequestInterceptor.class.getResource("/").getFile();
whiteUrls = FileUtil.readFile(path + "white/mrqWhite.txt");
_size = null == whiteUrls ? 0 : whiteUrls.size();
}

public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
Expand Down Expand Up @@ -91,13 +89,9 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons

/* 判断是否是白名单 */
private boolean isWhiteReq(String requestUrl) {
if (_size == 0) {
return true;
} else {
for (String urlTemp : whiteUrls) {
if (requestUrl.indexOf(urlTemp.toLowerCase()) > -1) {
return true;
}
for (String urlTemp : whiteUrls) {
if (requestUrl.indexOf(urlTemp.toLowerCase()) > -1) {
return true;
}
}
return false;
Expand Down

0 comments on commit 23f50e8

Please sign in to comment.