From 7bc262cbfa173fb0a31fb58d6f1d55fa0cac3b08 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Sat, 4 Feb 2023 18:39:59 +0900 Subject: - cursors - move guiv2 to launcher - add force letsencrypt support (without modifying keystore directly) ^ very cool Signed-off-by: syeyoung --- .../launcher/branch/UpdateRetrieverUtil.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch') diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java index 0414129c..ef282f1e 100644 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/branch/UpdateRetrieverUtil.java @@ -18,6 +18,7 @@ package kr.syeyoung.dungeonsguide.launcher.branch; +import kr.syeyoung.dungeonsguide.launcher.LetsEncrypt; import kr.syeyoung.dungeonsguide.launcher.Main; import kr.syeyoung.dungeonsguide.launcher.auth.AuthManager; import kr.syeyoung.dungeonsguide.launcher.exceptions.AssetNotFoundException; @@ -29,6 +30,7 @@ import org.apache.commons.io.IOUtils; import org.json.JSONArray; import org.json.JSONObject; +import javax.net.ssl.HttpsURLConnection; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; @@ -47,7 +49,8 @@ public class UpdateRetrieverUtil { } public static List getUpdateBranches() throws IOException { - HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/").openConnection(); + HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/").openConnection(); + connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); @@ -78,7 +81,8 @@ public class UpdateRetrieverUtil { } public static List getLatestUpdates(long branchId, int page) throws IOException { - HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/?page="+page).openConnection(); + HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/?page="+page).openConnection(); + connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestMethod("GET"); connection.setConnectTimeout(1000); @@ -120,7 +124,8 @@ public class UpdateRetrieverUtil { } public static Update getUpdate(long branchId, long updateId) throws IOException { - HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/"+updateId).openConnection(); + HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/"+branchId+"/"+updateId).openConnection(); + connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestProperty("Authorization", "Bearer "+ AuthManager.getInstance().getWorkingTokenOrThrow()); connection.setRequestMethod("GET"); @@ -162,7 +167,8 @@ public class UpdateRetrieverUtil { try { - HttpURLConnection connection = (HttpURLConnection) new URL(Main.DOMAIN + "/updates/" + update.getBranchId() + "/" + update.getId() + "/" + asset.getAssetId()).openConnection(); + HttpsURLConnection connection = (HttpsURLConnection) new URL(Main.DOMAIN + "/updates/" + update.getBranchId() + "/" + update.getId() + "/" + asset.getAssetId()).openConnection(); + connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setRequestMethod("GET"); connection.setRequestProperty("Authorization", "Bearer " + AuthManager.getInstance().getWorkingTokenOrThrow()); @@ -181,7 +187,8 @@ public class UpdateRetrieverUtil { throw new ResponseParsingException(payload, e); } try { - connection = (HttpURLConnection) new URL(url).openConnection(); + connection = (HttpsURLConnection) new URL(url).openConnection(); + connection.setSSLSocketFactory(LetsEncrypt.LETS_ENCRYPT); connection.setRequestProperty("User-Agent", "DungeonsGuide/4.0"); connection.setConnectTimeout(1000); connection.setReadTimeout(5000); -- cgit