use of org.jsmpp.session.connection.socket.SocketConnection in project camel by apache.
the class SmppConnectionFactory method createConnection.
public Connection createConnection(String host, int port) throws IOException {
try {
Socket socket;
SocketFactory socketFactory;
socketFactory = config.getUsingSSL() && config.getHttpProxyHost() == null ? SSLSocketFactory.getDefault() : SocketFactory.getDefault();
if (config.getHttpProxyHost() != null) {
// setup the proxy tunnel
socket = socketFactory.createSocket(config.getHttpProxyHost(), config.getHttpProxyPort());
connectProxy(host, port, socket);
} else {
socket = socketFactory.createSocket(host, port);
}
if (config.getUsingSSL() && config.getHttpProxyHost() != null) {
// Init the SSL socket which is based on the proxy socket
SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, host, port, true);
sslSocket.startHandshake();
socket = sslSocket;
}
return new SocketConnection(socket);
} catch (Exception e) {
throw new IOException(e.getMessage());
}
}
Aggregations