From 5a696438c38606a05e656158258f695a5c82acb3 Mon Sep 17 00:00:00 2001 From: Amir Bilu Date: Wed, 18 Oct 2023 14:10:13 +0300 Subject: [PATCH] support insecure mode --- .../tabnineCommon/binary/fetch/BinaryRemoteSource.java | 10 +++------- .../tabnineCommon/binary/fetch/GeneralDownloader.java | 5 ----- .../java/com/tabnineCommon/general/StaticConfig.java | 2 -- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Common/src/main/java/com/tabnineCommon/binary/fetch/BinaryRemoteSource.java b/Common/src/main/java/com/tabnineCommon/binary/fetch/BinaryRemoteSource.java index ed21c7b96..1dfa6b253 100644 --- a/Common/src/main/java/com/tabnineCommon/binary/fetch/BinaryRemoteSource.java +++ b/Common/src/main/java/com/tabnineCommon/binary/fetch/BinaryRemoteSource.java @@ -8,14 +8,10 @@ import java.io.IOException; import java.net.URL; import java.net.URLConnection; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; import java.util.List; import java.util.Optional; import org.jetbrains.annotations.NotNull; -import javax.net.ssl.HttpsURLConnection; - public class BinaryRemoteSource { @NotNull public Optional fetchPreferredVersion() { @@ -29,7 +25,7 @@ public Optional fetchPreferredVersion() { public Optional fetchPreferredVersion(String url) { try { return Optional.of(remoteVersionRequest(url)); - } catch (IOException | NoSuchAlgorithmException | KeyManagementException e) { + } catch (IOException e) { Logger.getInstance(getClass()) .warn("Request of current version failed. Falling back to latest local version.", e); return Optional.empty(); @@ -44,7 +40,7 @@ public Optional existingLocalBetaVersion(List loca return localVersions.stream() .filter(version -> remoteBetaVersion.equals(version.getVersion())) .findAny(); - } catch (IOException | NoSuchAlgorithmException | KeyManagementException e) { + } catch (IOException e) { Logger.getInstance(getClass()) .warn("Request of current version failed. Falling back to latest local version.", e); } @@ -53,7 +49,7 @@ public Optional existingLocalBetaVersion(List loca } @NotNull - private String remoteVersionRequest(String url) throws IOException, NoSuchAlgorithmException, KeyManagementException { + private String remoteVersionRequest(String url) throws IOException { URLConnection connection = new URL(url).openConnection(); connection.setConnectTimeout(StaticConfig.REMOTE_CONNECTION_TIMEOUT); diff --git a/Common/src/main/java/com/tabnineCommon/binary/fetch/GeneralDownloader.java b/Common/src/main/java/com/tabnineCommon/binary/fetch/GeneralDownloader.java index 49ed7125d..b99d889f2 100644 --- a/Common/src/main/java/com/tabnineCommon/binary/fetch/GeneralDownloader.java +++ b/Common/src/main/java/com/tabnineCommon/binary/fetch/GeneralDownloader.java @@ -6,7 +6,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.tabnineCommon.binary.exceptions.FailedToDownloadException; - import java.io.IOException; import java.net.URL; import java.net.URLConnection; @@ -14,8 +13,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; import java.util.UUID; public class GeneralDownloader { @@ -33,13 +30,11 @@ boolean download(String urlString, String destination, DownloadValidator validat URLConnection connection = new URL(urlString).openConnection(); connection.setConnectTimeout(REMOTE_CONNECTION_TIMEOUT); connection.setReadTimeout(BINARY_READ_TIMEOUT); - Files.copy(connection.getInputStream(), tempDestination, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { Logger.getInstance(GeneralDownloader.class).warn(e); return false; } - try { validator.validateAndRename(tempDestination, Paths.get(destination)); } catch (FailedToDownloadException e) { diff --git a/Common/src/main/java/com/tabnineCommon/general/StaticConfig.java b/Common/src/main/java/com/tabnineCommon/general/StaticConfig.java index f8d5cab76..67ce33704 100644 --- a/Common/src/main/java/com/tabnineCommon/general/StaticConfig.java +++ b/Common/src/main/java/com/tabnineCommon/general/StaticConfig.java @@ -12,7 +12,6 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.ObjectUtils; -import com.intellij.util.net.ssl.CertificateManager; import com.intellij.util.text.SemVer; import com.tabnineCommon.binary.exceptions.InvalidVersionPathException; import com.tabnineCommon.config.Config; @@ -20,7 +19,6 @@ import java.awt.*; import java.nio.file.Path; import java.nio.file.Paths; -import java.security.cert.X509Certificate; import java.util.*; import javax.swing.*; import org.jetbrains.annotations.NotNull;