1
13693261870
2022-09-16 fee60c3e25fac0982f3b8cb8feea7225c4ed22f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.terra.proxy.intercepter;
 
import com.terra.proxy.properties.TerraProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
 
import javax.servlet.*;
import java.io.IOException;
 
 
 
 
public class VisitInterceptor implements Filter {
    
        
    @Autowired
    private TerraProperties properties;
    
    public VisitInterceptor(TerraProperties prop){
        properties=prop;
    }
 
 
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        // TODO
    }
 
    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
          String fromips=req.getRemoteHost();
          String[] blackips= properties.getProxy().getBlacklist().split(";");
          for(String temp : blackips)
         if(temp.equals(fromips)||fromips.indexOf(temp)!=-1){
             return;
         }
        chain.doFilter(req, res);
        
    }
 
    @Override
    public void destroy() {
        // TODO
    }
 
 
    public static void main(String[] args) {
        String str="/50048/MapServer/export";
        String s= StringUtils.substringAfter(str,"Server");
        System.out.println("s = " + s);
 
    }
    
 
}