package com.eactive.eai.adapter.socket2.filter.ssl;
//package com.eactive.eai.adapter.socket2.protocol.ssl;
//
//import java.io.IOException;
//import java.net.InetAddress;
//import java.net.Socket;
//import java.net.UnknownHostException;
//import java.security.GeneralSecurityException;
//
//import javax.net.SocketFactory;
//
//import com.eactive.eai.adapter.socket2.config.SocketLoggerManager;
//import com.eactive.eai.common.util.Logger;
//
//
//public class SSLSocketFactory extends SocketFactory {
//	static final protected Logger logger = SocketLoggerManager.getInstance().getLogger();
//	static final protected Logger errLogger = SocketLoggerManager.getInstance().getErrLogger();
//
//	private static boolean sslEnabled = false;
//    private static javax.net.ssl.SSLSocketFactory sslFactory = null;
//    private static javax.net.SocketFactory factory = null;
//
//    public SSLSocketFactory() {
//        super();
//    }
//
//    public Socket createSocket(String arg1, int arg2) throws IOException, UnknownHostException {
//    	if (isSslEnabled()) {
//            return getSSLFactory().createSocket(arg1, arg2);
//        } else {
//            return new Socket(arg1, arg2);
//        }
//    }
//
//    public Socket createSocket(String arg1, int arg2, InetAddress arg3, int arg4) throws IOException, UnknownHostException {
//    	if (isSslEnabled()) {
//            return getSSLFactory().createSocket(arg1, arg2, arg3, arg4);
//        } else {
//            return new Socket(arg1, arg2, arg3, arg4);
//        }
//    }
//
//    public Socket createSocket(InetAddress arg1, int arg2) throws IOException {
//        if (isSslEnabled()) {
//            return getSSLFactory().createSocket(arg1, arg2);
//        } else {
//            return new Socket(arg1, arg2);
//        }
//    }
//
//    public Socket createSocket(InetAddress arg1, int arg2, InetAddress arg3, int arg4) throws IOException {
//		System.out.println("-SSLSocketFactory.createSocket()");
//
//		if (isSslEnabled()) {
//            return getSSLFactory().createSocket(arg1, arg2, arg3, arg4);
//        } else {
//            return new Socket(arg1, arg2, arg3, arg4);
//        }
//    }
//
//    public static javax.net.SocketFactory getSocketFactory() {
//        if (factory == null) {
//            factory = new SSLSocketFactory();
//        }
//        return factory;
//    }
//
//    private javax.net.ssl.SSLSocketFactory getSSLFactory() throws IOException {
//        if (sslFactory == null) {
//            try {
//                sslFactory = SSLContextFactory.createSSLContext(false).getSocketFactory();
//            } catch (GeneralSecurityException e) {
//                throw new RuntimeException("could not create SSL socket", e);
//            }
//        }
//        return sslFactory;
//    }
//
//    public static boolean isSslEnabled() {
//        return sslEnabled;
//    }
//
//    public static void setSslEnabled(boolean newSslEnabled) {
//        sslEnabled = newSslEnabled;
//    }
//
//}
