Skip to content

Commit

Permalink
Add Use SSL checkbox to Connect to Server dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
fishface60 committed Feb 11, 2025
1 parent d6d38fc commit fe9437e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ public JCheckBox getUsePublicKeyCheckBox() {
return (JCheckBox) getComponent("@usePublicKey");
}

@Nonnull
public JCheckBox getUseSSLCheckBox() {
if (getComponent("@useSSL") instanceof JCheckBox checkBox) {
return checkBox;
} else {
throw new AssertionError("Connect to server dialog should have a JCheckBox named @useSSL");
}
}

private void handleOK() {
String username = getUsernameTextField().getText().trim();
if (username.length() == 0) {
Expand Down Expand Up @@ -311,8 +320,14 @@ private void handleOK() {
}
getHostTextField().setText(host);

boolean useSSL = getUseSSLCheckBox().isSelected();

// OK
connectionDetails = new RemoteServerConfig.Socket(host, portTemp);
if (useSSL) {
connectionDetails = new RemoteServerConfig.SSLSocket(host, portTemp);
} else {
connectionDetails = new RemoteServerConfig.Socket(host, portTemp);
}
} else if (SwingUtil.hasComponent(selectedPanel, "rptoolsPanel")) {
String serverName = getServerNameTextField().getText().trim();
if (serverName.length() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ConnectToServerDialogPreferences {
private static final String KEY_TAB = "tab";
private static final String KEY_SERVER_NAME = "serverName";
private static final String USE_PUBLIC_KEY = "usePublicKey";
private static final String USE_SSL = "useSSL";
private static final String USE_WEB_RTC = "useWebRTC";

@Nonnull
Expand Down Expand Up @@ -100,4 +101,12 @@ public boolean getUseWebRTC() {
public void setUseWebRTC(boolean useWebRTC) {
prefs.putBoolean(USE_WEB_RTC, useWebRTC);
}

public boolean getUseSSL() {
return prefs.getBoolean(USE_SSL, false);
}

public void setUseSSL(boolean useSSL) {
prefs.putBoolean(USE_SSL, useSSL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,23 @@
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="59897" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Use SSL:"/>
</properties>
</component>
<component id="8e127" class="javax.swing.JCheckBox" binding="directUseSSLCheckbox">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<name value="@useSSL"/>
<text value=""/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
*/
package net.rptools.maptool.client.ui.connecttoserverdialog;

import java.awt.*;
import javax.swing.*;

public class ConnectToServerDialogView {
private JPanel mainPanel;
private JCheckBox directUseSSLCheckbox;

public JComponent getRootComponent() {
return mainPanel;
Expand Down

0 comments on commit fe9437e

Please sign in to comment.