-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReputationCheck
More file actions
34 lines (27 loc) · 915 Bytes
/
ReputationCheck
File metadata and controls
34 lines (27 loc) · 915 Bytes
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
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ReputationCheck {
public String CheckReputation(String url, ArrayList<String> maliciousWebsites) throws MalformedURLException {
String result = "Yes";
//System.out.println(url);
URL urlToCheck = new URL(url);
String host = urlToCheck.getHost();
Pattern pattern = Pattern.compile("^.*" + host + ".*$");
for(int i=0; i<maliciousWebsites.size(); i++)
{
Matcher matcher = pattern.matcher(maliciousWebsites.get(i));
if (matcher.find())
{
result = "No";
continue;
}
else
continue;
}
//System.out.println("Trustworthy? -- " + result);
return result;
}
}