diff options
author | Christoph Schulthess | 2016-12-01 17:08:08 +0100 |
---|---|---|
committer | Christoph Schulthess | 2016-12-01 17:08:08 +0100 |
commit | 362a31ab9d6ea47bd26e924d1d9a532c1bc43573 (patch) | |
tree | 48edb06e1930dfc4f66a320cf753a31cc0b0b57f | |
parent | cleaned task execute method (diff) | |
download | tmlite-bwlp-362a31ab9d6ea47bd26e924d1d9a532c1bc43573.tar.gz tmlite-bwlp-362a31ab9d6ea47bd26e924d1d9a532c1bc43573.tar.xz tmlite-bwlp-362a31ab9d6ea47bd26e924d1d9a532c1bc43573.zip |
meaningful comments
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/SSLRelayTask.java | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/SSLRelayTask.java b/src/main/java/org/openslx/taskmanager/tasks/SSLRelayTask.java index a9c0214..0109925 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/SSLRelayTask.java +++ b/src/main/java/org/openslx/taskmanager/tasks/SSLRelayTask.java @@ -43,15 +43,6 @@ public class SSLRelayTask extends AbstractTask { private Output status; - /** - * ###ONLY FOR TESTING### - * 1. initialize SocketFactory w/wo authentication - * ###ONLY FOR TESTING### - * - * 1a. set system properties (if auth==true) - * 2. initialize sockets to A and B - * 3. initialize relays to/from A and B - */ @Override protected boolean initTask() { @@ -92,6 +83,13 @@ public class SSLRelayTask extends AbstractTask { return close(); } + /** + * During testing phase there is the option to disable SSL/TLS authentication. + * THIS SHOULD BE REMOVED FOR ROLLOUT + * If auth == true, set system properties for key- and truststore and return default. + * Else, return SocketFactory from all-trusting SSLContext (returned by trustAll(). + * @return + */ private SSLSocketFactory initSSLSocketFactory () { if (auth) { System.setProperty("javax.net.ssl.keyStore", "keystore.jks"); @@ -112,6 +110,12 @@ public class SSLRelayTask extends AbstractTask { } } + /** + * Returns one Thread to run the relay. Is there a nicer way to do this? + * Scoping posed some difficulties + * @param source + * @return + */ private Thread initThread (char source) { if (source == 'a') { return new Thread() { @@ -146,14 +150,22 @@ public class SSLRelayTask extends AbstractTask { else return null; } - + /** + * Creates sockA and sockB + * @param ssf + * @throws IOException + * @throws UnknownHostException + */ private void initSockets (SSLSocketFactory ssf) throws IOException, UnknownHostException { sockA = (SSLSocket) ssf.createSocket(clientAIp, clientAPort); System.out.println("connected to " + clientAIp + " on port " + Integer.toString(clientAPort)); sockB = (SSLSocket) ssf.createSocket(clientBIp, clientBPort); System.out.println("connected to " + clientBIp + " on port " + Integer.toString(clientBPort)); } - + /** + * Creates relays aToB and bToA + * @throws IOException + */ private void initRelays () throws IOException { aToB = new Relay(sockA, sockB); System.out.println("relay created from " + clientAIp + " to " + clientBIp); @@ -162,7 +174,7 @@ public class SSLRelayTask extends AbstractTask { } /** - * Create all-trusting TrustManager for no-auth mode + * Create all-trusting TrustManager for no-auth mode and return SSLContext. */ private SSLContext trustAll () throws NoSuchAlgorithmException, KeyManagementException { TrustManager[] trustAllMan = new TrustManager[] {new X509TrustManager() { |