Skip to content

Commit 7a4ad79

Browse files
committed
Add Use SSL checkbox to Connect to Server dialog
1 parent 3a31262 commit 7a4ad79

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

src/main/java/net/rptools/maptool/client/ui/connecttoserverdialog/ConnectToServerDialog.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ public JCheckBox getUsePublicKeyCheckBox() {
260260
return (JCheckBox) getComponent("@usePublicKey");
261261
}
262262

263+
@Nonnull
264+
public JCheckBox getUseSSLCheckBox() {
265+
if (getComponent("@useSSL") instanceof JCheckBox checkBox) {
266+
return checkBox;
267+
} else {
268+
throw new AssertionError("Connect to server dialog should have a JCheckBox named @useSSL");
269+
}
270+
}
271+
263272
private void handleOK() {
264273
String username = getUsernameTextField().getText().trim();
265274
if (username.length() == 0) {
@@ -311,8 +320,14 @@ private void handleOK() {
311320
}
312321
getHostTextField().setText(host);
313322

323+
boolean useSSL = getUseSSLCheckBox().isSelected();
324+
314325
// OK
315-
connectionDetails = new RemoteServerConfig.Socket(host, portTemp);
326+
if (useSSL) {
327+
connectionDetails = new RemoteServerConfig.SSLSocket(host, portTemp);
328+
} else {
329+
connectionDetails = new RemoteServerConfig.Socket(host, portTemp);
330+
}
316331
} else if (SwingUtil.hasComponent(selectedPanel, "rptoolsPanel")) {
317332
String serverName = getServerNameTextField().getText().trim();
318333
if (serverName.length() == 0) {

src/main/java/net/rptools/maptool/client/ui/connecttoserverdialog/ConnectToServerDialogPreferences.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class ConnectToServerDialogPreferences {
3131
private static final String KEY_TAB = "tab";
3232
private static final String KEY_SERVER_NAME = "serverName";
3333
private static final String USE_PUBLIC_KEY = "usePublicKey";
34+
private static final String USE_SSL = "useSSL";
3435
private static final String USE_WEB_RTC = "useWebRTC";
3536

3637
@Nonnull
@@ -100,4 +101,12 @@ public boolean getUseWebRTC() {
100101
public void setUseWebRTC(boolean useWebRTC) {
101102
prefs.putBoolean(USE_WEB_RTC, useWebRTC);
102103
}
104+
105+
public boolean getUseSSL() {
106+
return prefs.getBoolean(USE_SSL, false);
107+
}
108+
109+
public void setUseSSL(boolean useSSL) {
110+
prefs.putBoolean(USE_SSL, useSSL);
111+
}
103112
}

src/main/java/net/rptools/maptool/client/ui/connecttoserverdialog/ConnectToServerDialogView.form

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,23 @@
227227
<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"/>
228228
</constraints>
229229
</hspacer>
230+
<component id="59897" class="javax.swing.JLabel">
231+
<constraints>
232+
<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"/>
233+
</constraints>
234+
<properties>
235+
<text value="Use SSL:"/>
236+
</properties>
237+
</component>
238+
<component id="8e127" class="javax.swing.JCheckBox" binding="directUseSSLCheckbox">
239+
<constraints>
240+
<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"/>
241+
</constraints>
242+
<properties>
243+
<name value="@useSSL"/>
244+
<text value=""/>
245+
</properties>
246+
</component>
230247
</children>
231248
</grid>
232249
</children>

src/main/java/net/rptools/maptool/client/ui/connecttoserverdialog/ConnectToServerDialogView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
*/
1515
package net.rptools.maptool.client.ui.connecttoserverdialog;
1616

17-
import java.awt.*;
1817
import javax.swing.*;
1918

2019
public class ConnectToServerDialogView {
2120
private JPanel mainPanel;
21+
private JCheckBox directUseSSLCheckbox;
2222

2323
public JComponent getRootComponent() {
2424
return mainPanel;

0 commit comments

Comments
 (0)