Mercurial > 510Connectbot
diff src/org/tn5250j/framework/transport/SocketConnector.java @ 8:3b760b39962a tn5250
adding tn5250 files
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 22 May 2014 15:41:35 -0700 |
parents | e8d2a24e85c6 |
children | e773d0952613 |
line wrap: on
line diff
--- a/src/org/tn5250j/framework/transport/SocketConnector.java Thu May 22 13:41:05 2014 -0700 +++ b/src/org/tn5250j/framework/transport/SocketConnector.java Thu May 22 15:41:35 2014 -0700 @@ -25,6 +25,7 @@ import java.net.Socket; +import org.tn5250j.framework.transport.SSL.SSLImplementation; import org.tn5250j.TN5250jConstants; import org.tn5250j.tools.logging.TN5250jLogFactory; import org.tn5250j.tools.logging.TN5250jLogger; @@ -44,7 +45,7 @@ /** * Set the type of SSL connection to use. Specify null or an empty string - * to use a plain socket. + * to use a plain socket. * @param type The SSL connection type * @see org.tn5250j.framework.transport.SSLConstants */ @@ -55,18 +56,18 @@ /** * Create a new client Socket to the given destination and port. If an SSL * socket type has not been specified <i>(by setSSLType(String))</i>, then - * a plain socket will be created. Otherwise, a new SSL socket of the + * a plain socket will be created. Otherwise, a new SSL socket of the * specified type will be created. * @param destination * @param port - * @return a new client socket, or null if + * @return a new client socket, or null if */ public Socket createSocket(String destination, int port) { Socket socket = null; Exception ex = null; - - if (sslType == null || sslType.trim().length() == 0 || + + if (sslType == null || sslType.trim().length() == 0 || sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { logger.info("Creating Plain Socket"); try { @@ -77,20 +78,17 @@ } } else { //SSL SOCKET - logger.info("Creating SSL ["+sslType+"] Socket"); - + logger.info("Creating SSL ["+sslType+"] Socket"); + SSLInterface sslIf = null; - - String sslImplClassName = - "org.tn5250j.framework.transport.SSL.SSLImplementation"; + try { - Class<?> c = Class.forName(sslImplClassName); - sslIf = (SSLInterface)c.newInstance(); + sslIf = (SSLInterface) new SSLImplementation(); } catch (Exception e) { ex = new Exception("Failed to create SSLInterface Instance. " + "Message is ["+e.getMessage()+"]"); } - + if (sslIf != null) { sslIf.init(sslType); socket = sslIf.createSSLSocket(destination,port); @@ -105,6 +103,6 @@ } return socket; } - - + + } \ No newline at end of file