Mercurial > 510Connectbot
comparison src/org/tn5250j/framework/transport/SocketConnector.java @ 112:77ac18bc1b2f
cleanup java formatting
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 18 Jun 2014 13:03:01 -0700 |
parents | 33eb63352be5 |
children |
comparison
equal
deleted
inserted
replaced
111:6a0ad4d384ea | 112:77ac18bc1b2f |
---|---|
34 | 34 |
35 | 35 |
36 public class SocketConnector { | 36 public class SocketConnector { |
37 private static final String TAG = "SocketConnector"; | 37 private static final String TAG = "SocketConnector"; |
38 | 38 |
39 /** | 39 /** |
40 * Creates a new instance that creates a plain socket by default. | 40 * Creates a new instance that creates a plain socket by default. |
41 */ | 41 */ |
42 public SocketConnector() { | 42 public SocketConnector() { |
43 } | |
43 | 44 |
44 } | 45 /** |
46 * Create a new client Socket to the given destination, port and sslType of | |
47 * encryption. | |
48 * @param destination | |
49 * @param port | |
50 * @return a new client socket, or null if | |
51 */ | |
52 public Socket createSocket(String destination, int port, String sslType, String homeDirectory, TerminalBridge bridge, TerminalManager manager) { | |
53 Socket socket = null; | |
54 Exception ex = null; | |
45 | 55 |
46 /** | 56 if (sslType == null || sslType.trim().length() == 0 || |
47 * Create a new client Socket to the given destination, port and sslType of | 57 sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { |
48 * encryption. | 58 Log.i(TAG, "Creating Plain Socket"); |
49 * @param destination | |
50 * @param port | |
51 * @return a new client socket, or null if | |
52 */ | |
53 public Socket createSocket(String destination, int port, String sslType, String homeDirectory, TerminalBridge bridge, TerminalManager manager) { | |
54 | 59 |
55 Socket socket = null; | 60 try { |
56 Exception ex = null; | 61 // Use Socket Constructor!!! SocketFactory for jdk 1.4 |
62 socket = new Socket(destination, port); | |
63 } | |
64 catch (Exception e) { | |
65 ex = e; | |
66 } | |
67 } | |
68 else { //SSL SOCKET | |
69 Log.i(TAG, "Creating SSL [" + sslType + "] Socket"); | |
70 SSLInterface sslIf = null; | |
57 | 71 |
58 if (sslType == null || sslType.trim().length() == 0 || | 72 try { |
59 sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { | 73 sslIf = (SSLInterface) new SSLImplementation(bridge, manager); |
60 Log.i(TAG,"Creating Plain Socket"); | 74 } |
61 try { | 75 catch (Exception e) { |
62 // Use Socket Constructor!!! SocketFactory for jdk 1.4 | 76 ex = new Exception("Failed to create SSLInterface Instance. " + |
63 socket = new Socket(destination,port); | 77 "Message is [" + e.getMessage() + "]"); |
64 } catch (Exception e) { | 78 } |
65 ex = e; | |
66 } | |
67 } else { //SSL SOCKET | |
68 | 79 |
69 Log.i(TAG,"Creating SSL ["+sslType+"] Socket"); | 80 if (sslIf != null) { |
81 sslIf.init(sslType, homeDirectory); | |
82 socket = sslIf.createSSLSocket(destination, port); | |
83 } | |
84 } | |
70 | 85 |
71 SSLInterface sslIf = null; | 86 if (ex != null) { |
87 Log.e(TAG, "exception", ex); | |
88 } | |
72 | 89 |
73 try { | 90 if (socket == null) { |
74 sslIf = (SSLInterface) new SSLImplementation(bridge, manager); | 91 Log.w(TAG, "No socket was created"); |
75 } catch (Exception e) { | 92 } |
76 ex = new Exception("Failed to create SSLInterface Instance. " + | |
77 "Message is ["+e.getMessage()+"]"); | |
78 } | |
79 | 93 |
80 if (sslIf != null) { | 94 return socket; |
81 sslIf.init(sslType, homeDirectory); | 95 } |
82 socket = sslIf.createSSLSocket(destination, port); | |
83 } | |
84 } | |
85 | |
86 if (ex != null) { | |
87 Log.e(TAG, "exception", ex); | |
88 } | |
89 if (socket == null) { | |
90 Log.w(TAG, "No socket was created"); | |
91 } | |
92 return socket; | |
93 } | |
94 | 96 |
95 | 97 |
96 } | 98 } |