tn5250j/src/org/tn5250j/framework/transport SSLConstants.java,NONE,1.1 SocketConnector.java,NONE,1.1 SSLInterface.java,NONE,1.1

"Kenneth J. Pouncey" <[email protected]> Sun, 01 Aug 2004 14:36:30 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/framework/transport
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6573/src/org/tn5250j/framework/transport

Added Files:
	SSLConstants.java SocketConnector.java SSLInterface.java 
Log Message:
Move transport to framework package

--- NEW FILE: SSLConstants.java ---
package org.tn5250j.framework.transport;

public interface SSLConstants {

  public static final String SSL_TYPE = "TN5250J_SSL_TYPE";
  public static final String SSL_TYPE_NONE = "NONE";
  public static final String SSL_TYPE_SSLv2 = "SSLv2";
  public static final String SSL_TYPE_SSLv3 = "SSLv3";
  public static final String SSL_TYPE_TLS = "TLS";

}
--- NEW FILE: SSLInterface.java ---
package org.tn5250j.framework.transport;

/*
 * @(#)SSLInterface.java
 *
 * Copyright:    Copyright (c) 2001
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA
 *
 */
import java.net.Socket;

public interface SSLInterface {

   public abstract void setSSLType(String type);

   public abstract Socket createSSLSocket(String destination, int port);

}
--- NEW FILE: SocketConnector.java ---

/*
 * @(#)SocketConnector.java
 * @author Steve Kennedy
 *
 * Copyright:    Copyright (c) 2001
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307 USA
 *
 */
package org.tn5250j.framework.transport;

import java.net.Socket;

public class SocketConnector {

  String sslType = null;


  public SocketConnector() {

    sslType = System.getProperty(SSLConstants.SSL_TYPE,SSLConstants.SSL_TYPE_NONE);
  }

  public void setSSLType(String type) {
    sslType = type;
  }

  public Socket createSocket(String destination, int port) {
    try {

      if (sslType.equals(SSLConstants.SSL_TYPE_NONE)) {
        System.out.println("Creating Socket");
        // for jdk 1.4
//        return SocketFactory.getDefault().createSocket(destination,port);
        return new Socket(destination,port);
      }

      //Using SSL Socket
      SSLInterface o = null;
      try {
         Class c = Class.forName("org.tn5250j.transport.SSL.SSLImplementation");
         o = (SSLInterface)c.newInstance();
         o.setSSLType(sslType);
         return o.createSSLSocket(destination,port);
      }
      catch (Exception e) {
         System.err.println(e);
      }
    }
    catch (Exception e) {
      System.err.println("SocketConnector: createSocket: " + e.getMessage());
    }
    return null;
  }
}


-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com