mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
Separate HTTPS proxy support (server and port)
This commit is contained in:
parent
29d20f297c
commit
59b8177916
@ -213,8 +213,10 @@ public class Preferences {
|
|||||||
JCheckBox autoAssociateBox;
|
JCheckBox autoAssociateBox;
|
||||||
JComboBox comboLanguage;
|
JComboBox comboLanguage;
|
||||||
JCheckBox saveVerifyUploadBox;
|
JCheckBox saveVerifyUploadBox;
|
||||||
JTextField proxyServer;
|
JTextField proxyHTTPServer;
|
||||||
JTextField proxyPort;
|
JTextField proxyHTTPPort;
|
||||||
|
JTextField proxyHTTPSServer;
|
||||||
|
JTextField proxyHTTPSPort;
|
||||||
JTextField proxyUser;
|
JTextField proxyUser;
|
||||||
JPasswordField proxyPassword;
|
JPasswordField proxyPassword;
|
||||||
|
|
||||||
@ -551,28 +553,41 @@ public class Preferences {
|
|||||||
private void setupProxySettingsFieldSet(Container pane) {
|
private void setupProxySettingsFieldSet(Container pane) {
|
||||||
|
|
||||||
JPanel proxySettingsPanel = new JPanel();
|
JPanel proxySettingsPanel = new JPanel();
|
||||||
JLabel jLabel2 = new JLabel();
|
|
||||||
proxyServer = new JTextField();
|
JLabel proxyHTTPServerLabel = new JLabel();
|
||||||
JLabel jLabel3 = new JLabel();
|
proxyHTTPServer = new JTextField();
|
||||||
proxyPort = new JTextField();
|
JLabel proxyHTTPPortLabel = new JLabel();
|
||||||
JLabel jLabel4 = new JLabel();
|
proxyHTTPPort = new JTextField();
|
||||||
|
JLabel proxyHTTPSServerLabel = new JLabel();
|
||||||
|
proxyHTTPSServer = new JTextField();
|
||||||
|
JLabel proxyHTTPSPortLabel = new JLabel();
|
||||||
|
proxyHTTPSPort = new JTextField();
|
||||||
|
JLabel proxyUserLabel = new JLabel();
|
||||||
proxyUser = new JTextField();
|
proxyUser = new JTextField();
|
||||||
JLabel jLabel5 = new JLabel();
|
JLabel proxyPasswordLabel = new JLabel();
|
||||||
proxyPassword = new JPasswordField();
|
proxyPassword = new JPasswordField();
|
||||||
|
|
||||||
proxySettingsPanel.setBorder(BorderFactory.createTitledBorder(_("Proxy Settings")));
|
proxySettingsPanel.setBorder(BorderFactory.createTitledBorder(_("Proxy Settings")));
|
||||||
|
|
||||||
jLabel2.setText(_("Server:"));
|
proxyHTTPServerLabel.setText(_("Server (HTTP):"));
|
||||||
|
|
||||||
proxyServer.setColumns(10);
|
proxyHTTPServer.setColumns(10);
|
||||||
|
|
||||||
jLabel3.setText(_("Port:"));
|
proxyHTTPPortLabel.setText(_("Port (HTTP):"));
|
||||||
|
|
||||||
proxyPort.setColumns(10);
|
proxyHTTPPort.setColumns(10);
|
||||||
|
|
||||||
jLabel4.setText(_("Username:"));
|
proxyHTTPSServerLabel.setText(_("Server: (HTTPS)"));
|
||||||
|
|
||||||
jLabel5.setText(_("Password:"));
|
proxyHTTPSServer.setColumns(10);
|
||||||
|
|
||||||
|
proxyHTTPSPortLabel.setText(_("Port (HTTPS):"));
|
||||||
|
|
||||||
|
proxyHTTPSPort.setColumns(10);
|
||||||
|
|
||||||
|
proxyUserLabel.setText(_("Username:"));
|
||||||
|
|
||||||
|
proxyPasswordLabel.setText(_("Password:"));
|
||||||
|
|
||||||
GroupLayout proxySettingsPanelLayout = new GroupLayout(proxySettingsPanel);
|
GroupLayout proxySettingsPanelLayout = new GroupLayout(proxySettingsPanel);
|
||||||
proxySettingsPanel.setLayout(proxySettingsPanelLayout);
|
proxySettingsPanel.setLayout(proxySettingsPanelLayout);
|
||||||
@ -581,35 +596,45 @@ public class Preferences {
|
|||||||
.addGroup(proxySettingsPanelLayout.createSequentialGroup()
|
.addGroup(proxySettingsPanelLayout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(jLabel4)
|
.addComponent(proxyUserLabel)
|
||||||
.addComponent(jLabel2))
|
.addComponent(proxyHTTPSServerLabel)
|
||||||
|
.addComponent(proxyHTTPServerLabel))
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(proxyServer)
|
.addComponent(proxyHTTPServer)
|
||||||
|
.addComponent(proxyHTTPSServer)
|
||||||
.addComponent(proxyUser))
|
.addComponent(proxyUser))
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING)
|
||||||
.addComponent(jLabel5)
|
.addComponent(proxyPasswordLabel)
|
||||||
.addComponent(jLabel3))
|
.addComponent(proxyHTTPSPortLabel)
|
||||||
|
.addComponent(proxyHTTPPortLabel))
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
|
||||||
.addComponent(proxyPassword)
|
.addComponent(proxyPassword)
|
||||||
.addComponent(proxyPort))
|
.addComponent(proxyHTTPSPort)
|
||||||
|
.addComponent(proxyHTTPPort))
|
||||||
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
proxySettingsPanelLayout.setVerticalGroup(
|
proxySettingsPanelLayout.setVerticalGroup(
|
||||||
proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(proxySettingsPanelLayout.createSequentialGroup()
|
.addGroup(proxySettingsPanelLayout.createSequentialGroup()
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel2)
|
.addComponent(proxyHTTPServerLabel)
|
||||||
.addComponent(proxyServer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(proxyHTTPServer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jLabel3)
|
.addComponent(proxyHTTPPortLabel)
|
||||||
.addComponent(proxyPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(proxyHTTPPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel4)
|
.addComponent(proxyHTTPSServerLabel)
|
||||||
|
.addComponent(proxyHTTPSServer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(proxyHTTPSPortLabel)
|
||||||
|
.addComponent(proxyHTTPSPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
|
||||||
|
.addGroup(proxySettingsPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(proxyUserLabel)
|
||||||
.addComponent(proxyUser, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
.addComponent(proxyUser, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(jLabel5)
|
.addComponent(proxyPasswordLabel)
|
||||||
.addComponent(proxyPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
.addComponent(proxyPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -627,7 +652,6 @@ public class Preferences {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
// .................................................................
|
// .................................................................
|
||||||
|
|
||||||
|
|
||||||
@ -707,11 +731,17 @@ public class Preferences {
|
|||||||
Language newLanguage = (Language) comboLanguage.getSelectedItem();
|
Language newLanguage = (Language) comboLanguage.getSelectedItem();
|
||||||
PreferencesData.set("editor.languages.current", newLanguage.isoCode);
|
PreferencesData.set("editor.languages.current", newLanguage.isoCode);
|
||||||
|
|
||||||
Preferences.set("proxy.server", proxyServer.getText());
|
Preferences.set("proxy.http.server", proxyHTTPServer.getText());
|
||||||
try {
|
try {
|
||||||
Preferences.set("proxy.port", Integer.valueOf(proxyPort.getText()).toString());
|
Preferences.set("proxy.http.port", Integer.valueOf(proxyHTTPPort.getText()).toString());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Preferences.remove("proxy.port");
|
Preferences.remove("proxy.http.port");
|
||||||
|
}
|
||||||
|
Preferences.set("proxy.https.server", proxyHTTPServer.getText());
|
||||||
|
try {
|
||||||
|
Preferences.set("proxy.https.port", Integer.valueOf(proxyHTTPPort.getText()).toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Preferences.remove("proxy.https.port");
|
||||||
}
|
}
|
||||||
Preferences.set("proxy.user", proxyUser.getText());
|
Preferences.set("proxy.user", proxyUser.getText());
|
||||||
Preferences.set("proxy.password", new String(proxyPassword.getPassword()));
|
Preferences.set("proxy.password", new String(proxyPassword.getPassword()));
|
||||||
@ -747,11 +777,17 @@ public class Preferences {
|
|||||||
|
|
||||||
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));
|
updateExtensionBox.setSelected(PreferencesData.get("editor.update_extension") == null || PreferencesData.getBoolean("editor.update_extension"));
|
||||||
|
|
||||||
proxyServer.setText(Preferences.get("proxy.server"));
|
proxyHTTPServer.setText(Preferences.get("proxy.http.server"));
|
||||||
try {
|
try {
|
||||||
proxyPort.setText(Integer.toString(Preferences.getInteger("proxy.port")));
|
proxyHTTPPort.setText(Integer.toString(Preferences.getInteger("proxy.http.port", 8080)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
proxyPort.setText("");
|
proxyHTTPPort.setText("");
|
||||||
|
}
|
||||||
|
proxyHTTPServer.setText(Preferences.get("proxy.https.server"));
|
||||||
|
try {
|
||||||
|
proxyHTTPPort.setText(Integer.toString(Preferences.getInteger("proxy.https.port", 8443)));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
proxyHTTPPort.setText("");
|
||||||
}
|
}
|
||||||
proxyUser.setText(Preferences.get("proxy.user"));
|
proxyUser.setText(Preferences.get("proxy.user"));
|
||||||
proxyPassword.setText(Preferences.get("proxy.password"));
|
proxyPassword.setText(Preferences.get("proxy.password"));
|
||||||
|
@ -30,7 +30,6 @@ package cc.arduino.utils.network;
|
|||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import processing.app.PreferencesData;
|
import processing.app.PreferencesData;
|
||||||
import processing.app.helpers.StringUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -122,23 +121,28 @@ public class FileDownloader extends Observable {
|
|||||||
|
|
||||||
setStatus(Status.CONNECTING);
|
setStatus(Status.CONNECTING);
|
||||||
|
|
||||||
if (PreferencesData.has("proxy.server") && PreferencesData.get("proxy.server") != null && !PreferencesData.get("proxy.server").equals("")) {
|
System.getProperties().remove("http.proxyHost");
|
||||||
System.getProperties().put("http.proxyHost", PreferencesData.get("proxy.server"));
|
System.getProperties().remove("http.proxyPort");
|
||||||
System.getProperties().put("http.proxyPort", PreferencesData.get("proxy.port"));
|
System.getProperties().remove("https.proxyHost");
|
||||||
System.getProperties().put("https.proxyHost", PreferencesData.get("proxy.server"));
|
System.getProperties().remove("https.proxyPort");
|
||||||
System.getProperties().put("https.proxyPort", PreferencesData.get("proxy.port"));
|
System.getProperties().remove("http.proxyUser");
|
||||||
if (PreferencesData.has("proxy.user")) {
|
System.getProperties().remove("http.proxyPassword");
|
||||||
System.getProperties().put("http.proxyUser", PreferencesData.get("proxy.user"));
|
|
||||||
System.getProperties().put("http.proxyPassword", PreferencesData.get("proxy.password"));
|
if (PreferencesData.has("proxy.http.server") && PreferencesData.get("proxy.http.server") != null && !PreferencesData.get("proxy.http.server").equals("")) {
|
||||||
}
|
System.getProperties().put("http.proxyHost", PreferencesData.get("proxy.http.server"));
|
||||||
} else {
|
System.getProperties().put("http.proxyPort", PreferencesData.get("proxy.http.port"));
|
||||||
System.getProperties().remove("http.proxyHost");
|
|
||||||
System.getProperties().remove("http.proxyPort");
|
|
||||||
System.getProperties().remove("https.proxyHost");
|
|
||||||
System.getProperties().remove("https.proxyPort");
|
|
||||||
System.getProperties().remove("http.proxyUser");
|
|
||||||
System.getProperties().remove("http.proxyPassword");
|
|
||||||
}
|
}
|
||||||
|
if (PreferencesData.has("proxy.https.server") && PreferencesData.get("proxy.https.server") != null && !PreferencesData.get("proxy.https.server").equals("")) {
|
||||||
|
System.getProperties().put("https.proxyHost", PreferencesData.get("proxy.https.server"));
|
||||||
|
System.getProperties().put("https.proxyPort", PreferencesData.get("proxy.https.port"));
|
||||||
|
}
|
||||||
|
if (PreferencesData.has("proxy.user") && PreferencesData.get("proxy.user") != null && !PreferencesData.get("proxy.user").equals("")) {
|
||||||
|
System.getProperties().put("http.proxyUser", PreferencesData.get("proxy.user"));
|
||||||
|
System.getProperties().put("http.proxyPassword", PreferencesData.get("proxy.password"));
|
||||||
|
System.getProperties().put("https.proxyUser", PreferencesData.get("proxy.user"));
|
||||||
|
System.getProperties().put("https.proxyPassword", PreferencesData.get("proxy.password"));
|
||||||
|
}
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
|
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
|
||||||
|
|
||||||
if (downloadUrl.getUserInfo() != null) {
|
if (downloadUrl.getUserInfo() != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user