diff options
| author | Simon Rettberg | 2015-09-09 14:09:05 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-09-09 14:09:05 +0200 |
| commit | dfecffaa73ca8cbaeb83d14eac21fbe55444ba8c (patch) | |
| tree | 4eee62a283be9dfcac05c60a5a49f0279137d735 | |
| parent | [server] Make master server ssl/port configurable (diff) | |
| download | tutor-module-dfecffaa73ca8cbaeb83d14eac21fbe55444ba8c.tar.gz tutor-module-dfecffaa73ca8cbaeb83d14eac21fbe55444ba8c.tar.xz tutor-module-dfecffaa73ca8cbaeb83d14eac21fbe55444ba8c.zip | |
[client] Allow setting master server address via command line
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/App.java | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java index fe0781e4..eeced8fc 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/App.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/App.java @@ -7,7 +7,6 @@ import java.awt.event.AWTEventListener; import java.awt.event.ContainerEvent; import java.io.File; import java.io.IOException; -import java.security.NoSuchAlgorithmException; import java.util.HashSet; import java.util.Set; import java.util.regex.Matcher; @@ -148,21 +147,36 @@ public class App { adjustFontSize(Config.getFontScaling()); // setup global thrift connection error handler before anything else - // Set master server to use (TODO: make configurable via command line) - try { - ThriftManager.setMasterServerAddress(SSLContext.getDefault(), - "bwlp-masterserver.ruf.uni-freiburg.de", THRIFT_SSL_PORT, THRIFT_TIMEOUT_MS); - } catch (final NoSuchAlgorithmException e1) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - Gui.showMessageBox(null, "SSL nicht verfügbar", MessageType.ERROR, LOGGER, e1); - // TODO: Ask if user wants to establish plain connection, quit otherwise - System.exit(1); - } - }); - return; + // Set master server to use + String host; + int port; + boolean useSsl; + if (args.length == 3) { + host = args[0]; + port = Util.parseInt(args[1], -1); + useSsl = Boolean.getBoolean(args[2]); + } else { + host = "bwlp-masterserver.ruf.uni-freiburg.de"; + port = THRIFT_SSL_PORT; + useSsl = true; + } + SSLContext ctx = null; + if (useSsl) { + try { + ctx = SSLContext.getDefault(); + } catch (final Exception e1) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Gui.showMessageBox(null, "SSL nicht verfügbar", MessageType.ERROR, LOGGER, e1); + // TODO: Ask if user wants to establish plain connection, quit otherwise + System.exit(1); + } + }); + return; + } } + ThriftManager.setMasterServerAddress(ctx, host, port, THRIFT_TIMEOUT_MS); SwingUtilities.invokeLater(new Runnable() { @Override |
