Skip to content

Commit

Permalink
support insecure mode
Browse files Browse the repository at this point in the history
  • Loading branch information
amirbilu committed Oct 18, 2023
1 parent 6a063b7 commit 5a69643
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> fetchPreferredVersion() {
Expand All @@ -29,7 +25,7 @@ public Optional<String> fetchPreferredVersion() {
public Optional<String> 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();
Expand All @@ -44,7 +40,7 @@ public Optional<BinaryVersion> existingLocalBetaVersion(List<BinaryVersion> 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);
}
Expand All @@ -53,7 +49,7 @@ public Optional<BinaryVersion> existingLocalBetaVersion(List<BinaryVersion> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

import com.intellij.openapi.diagnostic.Logger;
import com.tabnineCommon.binary.exceptions.FailedToDownloadException;

import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
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;
import com.tabnineCommon.userSettings.AppSettingsState;
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;
Expand Down

0 comments on commit 5a69643

Please sign in to comment.