diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..870a325
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..146ab09
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..1c24f9a
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_guava_guava_21_0.xml b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
new file mode 100644
index 0000000..a923456
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_guava_guava_21_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..5faeabe
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..9f4bb74
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..fc96c37
--- /dev/null
+++ b/.idea/workspace.x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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1504604417100
+
+
+ 1504604417100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..e15928a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,18 @@
+
+
+ 4.0.0
+
+ trident
+ trident
+ 1.0.0
+
+
+
+ com.google.guava
+ guava
+ 21.0
+
+
+
\ No newline at end of file
diff --git a/src/main/java/main.java b/src/main/java/main.java
new file mode 100644
index 0000000..ea54c97
--- /dev/null
+++ b/src/main/java/main.java
@@ -0,0 +1,43 @@
+/**
+ * Created by Viarus on 17/9/5.
+ */
+
+import java.net.URL;
+import com.google.common.net.InternetDomainName;
+
+public class main {
+
+ /*
+ * 检测传入的URL是否在白名单的域名里
+ * url:需要检测的URL
+ * urlWList: 一级域名的域名列表,比如String[] urlWList = {"joychou.com", "joychou.me"};
+ * 合法URL返回true,非法URL返回false
+ */
+ public static Boolean checkUrlWlist(String url, String[] urlWList) {
+ try {
+ URL u = new URL(url);
+ // 只允许http和https的协议
+ if (!u.getProtocol().startsWith("http") && !u.getProtocol().startsWith("https")) {
+ return false;
+ }
+ // 获取域名,并转为小写
+ String host = u.getHost().toLowerCase();
+ // 获取一级域名
+ String rootDomain = InternetDomainName.from(host).topPrivateDomain().toString();
+
+ for (String whiteUrl: urlWList){
+ if (rootDomain.equals(whiteUrl)) {
+ return true;
+ }
+ }
+ return false;
+
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+
+ }
+}
diff --git a/src/main/java/test.java b/src/main/java/test.java
new file mode 100644
index 0000000..87e5660
--- /dev/null
+++ b/src/main/java/test.java
@@ -0,0 +1,11 @@
+/**
+ * Created by Viarus on 17/9/5.
+ */
+public class test {
+ public static void main(String[] args) throws Exception {
+ main checkUrl = new main();
+ String[] urlWList = {"joychou.com", "joychou.me"};
+ Boolean ret = checkUrl.checkUrlWlist("http://test.joychou.me", urlWList);
+ System.out.println(ret);
+ }
+}
diff --git a/target/classes/main.class b/target/classes/main.class
new file mode 100644
index 0000000..090f851
Binary files /dev/null and b/target/classes/main.class differ
diff --git a/target/classes/test.class b/target/classes/test.class
new file mode 100644
index 0000000..98187cf
Binary files /dev/null and b/target/classes/test.class differ
diff --git a/trident.iml b/trident.iml
new file mode 100644
index 0000000..e24b78b
--- /dev/null
+++ b/trident.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file