From fc8c9d874891a629382ee10ab84e5b3fd332dbd9 Mon Sep 17 00:00:00 2001 From: games647 Date: Sun, 28 Mar 2021 22:41:03 +0200 Subject: [PATCH] Open GEO connection after checking config values (Related #2289) --- src/main/java/fr/xephi/authme/service/GeoIpService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/service/GeoIpService.java b/src/main/java/fr/xephi/authme/service/GeoIpService.java index 091faa4e..808ae98a 100644 --- a/src/main/java/fr/xephi/authme/service/GeoIpService.java +++ b/src/main/java/fr/xephi/authme/service/GeoIpService.java @@ -186,8 +186,6 @@ public class GeoIpService { * @throws IOException if failed during downloading and writing to destination file */ private String downloadDatabaseArchive(Instant lastModified, Path destination) throws IOException { - HttpURLConnection connection = (HttpURLConnection) new URL(ARCHIVE_URL).openConnection(); - String clientId = settings.getProperty(ProtectionSettings.MAXMIND_API_CLIENT_ID); String licenseKey = settings.getProperty(ProtectionSettings.MAXMIND_API_LICENSE_KEY); if (clientId.isEmpty() || licenseKey.isEmpty()) { @@ -195,6 +193,8 @@ public class GeoIpService { + " GeoIp protections will be disabled."); return null; } + + HttpURLConnection connection = (HttpURLConnection) new URL(ARCHIVE_URL).openConnection(); String basicAuth = "Basic " + new String(Base64.getEncoder().encode((clientId + ":" + licenseKey).getBytes())); connection.setRequestProperty("Authorization", basicAuth);