comparison src/ch/ethz/ssh2/transport/ClientTransportManager.java @ 273:91a31873c42a ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 11:21:46 -0700
parents
children ca5dd224a87b
comparison
equal deleted inserted replaced
272:ce2f4e397703 273:91a31873c42a
1 package ch.ethz.ssh2.transport;
2
3 import java.io.IOException;
4 import java.net.InetSocketAddress;
5 import java.net.Socket;
6 import java.security.SecureRandom;
7
8 import ch.ethz.ssh2.DHGexParameters;
9 import ch.ethz.ssh2.ServerHostKeyVerifier;
10 import ch.ethz.ssh2.crypto.CryptoWishList;
11
12 /**
13 * @version $Id: ClientTransportManager.java 151 2014-04-28 10:03:39Z dkocher@sudo.ch $
14 */
15 public class ClientTransportManager extends TransportManager {
16
17 private final Socket sock;
18
19 public ClientTransportManager(final Socket socket) {
20 super(socket);
21 this.sock = socket;
22 }
23
24 public void setTcpNoDelay(boolean state) throws IOException {
25 sock.setTcpNoDelay(state);
26 }
27
28 public void setSoTimeout(int timeout) throws IOException {
29 sock.setSoTimeout(timeout);
30 }
31
32 public void connect(String hostname, int port, String softwareversion, CryptoWishList cwl,
33 ServerHostKeyVerifier verifier, DHGexParameters dhgex, int connectTimeout, SecureRandom rnd)
34 throws IOException {
35 // Establish the TCP connection to the SSH-2 server
36 this.connect(hostname, port, connectTimeout);
37
38 // Parse the server line and say hello - important: this information is later needed for the
39 // key exchange (to stop man-in-the-middle attacks) - that is why we wrap it into an object
40 // for later use.
41
42 ClientServerHello csh = ClientServerHello.clientHello(softwareversion, sock.getInputStream(),
43 sock.getOutputStream());
44
45 TransportConnection tc = new TransportConnection(sock.getInputStream(), sock.getOutputStream(), rnd);
46
47 KexManager km = new ClientKexManager(this, csh, cwl, hostname, port, verifier, rnd);
48 super.init(tc, km);
49
50 km.initiateKEX(cwl, dhgex, null, null);
51
52 this.startReceiver();
53 }
54
55 protected void connect(String hostname, int port, int connectTimeout)
56 throws IOException {
57 sock.connect(new InetSocketAddress(hostname, port), connectTimeout);
58 }
59 }