summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryinjiangyi <[email protected]>2021-12-23 17:30:01 +0800
committeryinjiangyi <[email protected]>2021-12-23 17:30:01 +0800
commit64f03cd412d60cff39cdc4215f876b5c88e75a4b (patch)
tree49e30ea816c2e6e8f6e487585bc128e55d78bf67
parentc23ff905f46b1b0a2aaa00a2fc4c89d0990bb365 (diff)
创建whois接口调用分支for_wcx_whois
-rw-r--r--src/main/java/cn/ac/iie/utils/DomainWhoisUtils.java92
-rw-r--r--src/main/resources/application.properties2
2 files changed, 93 insertions, 1 deletions
diff --git a/src/main/java/cn/ac/iie/utils/DomainWhoisUtils.java b/src/main/java/cn/ac/iie/utils/DomainWhoisUtils.java
new file mode 100644
index 0000000..d9d8d40
--- /dev/null
+++ b/src/main/java/cn/ac/iie/utils/DomainWhoisUtils.java
@@ -0,0 +1,92 @@
+package cn.ac.iie.utils;
+
+import cn.ac.iie.config.CommonConfig;
+import cn.ac.iie.dao.FqdnFile;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.log4j.Logger;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.sql.Timestamp;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: joy
+ * Date: 2021/12/23
+ * Time: 5:13 PM
+ * Description: No Description
+ */
+public class DomainWhoisUtils {
+ private static final Logger LOG = Logger.getLogger(BrightCloudUtils.class);
+ private static final Properties props = new Properties();
+ private HttpURLConnection con;
+
+ public JSONObject getQueryResults (List<String> fqdns, String queryType) {
+ JSONObject jsonRes = null;
+ // 调用接口查询fqdns, 返回结果生成JSONObject
+
+ return jsonRes;
+ }
+
+ public List<FqdnFile> responseSparse(JSONObject records){
+ List<FqdnFile> fqdnFiles = new ArrayList<>();
+ Boolean querySucess = records.get("status").equals(200);
+
+ if (!querySucess) {
+ System.out.print(records.toString());
+ LOG.error("Wrong query. Query type: " + records.get("type"));
+ } else {
+ JSONArray array = records.getJSONArray("results");
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject jo = array.getJSONObject(i);
+
+ // json处理
+
+
+
+ // 生成fqdnFile对象
+ // FqdnFile file = new FqdnFile();
+ /** 构造器参考
+ public FqdnFile(String fqdn, Boolean query_success,
+ String whoisDomain, Date whoisUpdateDate, Date whoisCreateDate, Date whoisExpireDate,
+ String whoisEmail, String whoisNs, String whoisRegistrarName, String whoisRegistrantOrg,
+ String whoisRegisranteName, String whoisRegisranteStreet, String whoisRegisranteCity,
+ String whoisRegisranteState, String whoisRegisrantePostcode, String whoisRegisranteCountry,
+ String whoisRegisrantePhone) {
+
+ this.fqdn = fqdn;
+ this.query_success = query_success;
+ this.match_pattern = getMatchPattern(fqdn);
+
+ this.whois_domain = getEffectiveString(whoisDomain);
+ this.whois_update_date = whoisUpdateDate == null ? null : new Timestamp(whoisUpdateDate.getTime());
+ this.whois_create_date = whoisCreateDate == null ? null : new Timestamp(whoisCreateDate.getTime());
+ this.whois_expire_date = whoisExpireDate == null ? null : new Timestamp(whoisExpireDate.getTime());
+ this.whois_email = getEffectiveString(whoisEmail);
+ this.whois_ns = getEffectiveString(whoisNs);
+ this.whois_registrar_name = getEffectiveString(whoisRegistrarName);
+ this.whois_registrant_org = getEffectiveString(whoisRegistrantOrg);
+ this.whois_regisrante_name = getEffectiveString(whoisRegisranteName);
+ this.whois_regisrante_street = getEffectiveString(whoisRegisranteStreet);
+ this.whois_regisrante_city = getEffectiveString(whoisRegisranteCity);
+ this.whois_regisrante_state = getEffectiveString(whoisRegisranteState);
+ this.whois_regisrante_postcode = getEffectiveString(whoisRegisrantePostcode);
+ this.whois_regisrante_country = getEffectiveString(whoisRegisranteCountry);
+ this.whois_regisrante_phone = getEffectiveString(whoisRegisrantePhone);
+ }
+ fqdnFiles.add(file);
+ **/
+
+ }
+ }
+ return fqdnFiles;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b73a227..99716f2 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -11,7 +11,7 @@ offline.switch = false
update.switch = false
query.url_info.switch = false
query.url_rep.switch = false
-query.url_whois.switch = false
+query.url_whois.switch = true
# 离线导入文件后缀名
offline.import.filename.suffix = .compl