16
16
import ch .ethz .ssh2 .server .ServerConnectionState ;
17
17
import ch .ethz .ssh2 .signature .DSAPrivateKey ;
18
18
import ch .ethz .ssh2 .signature .RSAPrivateKey ;
19
- import ch .ethz .ssh2 .transport .TransportManager ;
19
+ import ch .ethz .ssh2 .transport .ServerTransportManager ;
20
20
21
21
/**
22
22
* A server-side SSH-2 connection.
23
- *
23
+ *
24
24
* @author Christian
25
25
*
26
26
*/
@@ -39,9 +39,9 @@ public class ServerConnection
39
39
* <p>
40
40
* Note: you need to call {@link #connect()} or {@link #connect(int)} to
41
41
* perform the initial handshake and establish the encrypted communication.
42
- *
42
+ *
43
43
* @see #connect(int)
44
- *
44
+ *
45
45
* @param s The socket
46
46
*/
47
47
public ServerConnection (Socket s )
@@ -62,9 +62,9 @@ public ServerConnection(Socket s, String softwareversion) {
62
62
* perform the initial handshake and establish the encrypted communication.
63
63
* <p>
64
64
* Please read the javadoc for the {@link #connect(int)} method.
65
- *
65
+ *
66
66
* @see #connect(int)
67
- *
67
+ *
68
68
* @param s The socket
69
69
* @param dsa_key The DSA hostkey, may be <code>NULL</code>
70
70
* @param rsa_key The RSA hostkey, may be <code>NULL</code>
@@ -84,9 +84,9 @@ public ServerConnection(Socket s, DSAPrivateKey dsa_key, RSAPrivateKey rsa_key)
84
84
* Note: this is a wrapper that calls <code>connect(0)</code> (i.e., connect with no timeout).
85
85
* <p>
86
86
* Please read the javadoc for the {@link #connect(int)} method.
87
- *
87
+ *
88
88
* @see #connect(int)
89
- *
89
+ *
90
90
* @throws IOException
91
91
*/
92
92
public synchronized void connect () throws IOException
@@ -101,12 +101,12 @@ public synchronized void connect() throws IOException
101
101
* <p>
102
102
* Note 2: You must set the callbacks for authentication ({@link #setAuthenticationCallback(ServerAuthenticationCallback)})
103
103
* and connection events ({@link #setServerConnectionCallback(ServerConnectionCallback)}).
104
- *
104
+ *
105
105
* @see #setPEMHostKey(char[], String)
106
106
* @see #setPEMHostKey(File, String)
107
107
* @see #setRsaHostKey(RSAPrivateKey)
108
108
* @see #setDsaHostKey(DSAPrivateKey)
109
- *
109
+ *
110
110
* @param timeout_milliseconds Timeout in milliseconds, <code>0</code> means no timeout.
111
111
* @throws IOException
112
112
*/
@@ -126,14 +126,10 @@ public synchronized void connect(int timeout_milliseconds) throws IOException
126
126
if ((state .next_dsa_key == null ) && (state .next_rsa_key == null ))
127
127
throw new IllegalStateException ("Neither a RSA nor a DSA host key has been specified!" );
128
128
129
- state .tm = new TransportManager ( );
129
+ state .tm = new ServerTransportManager ( state . s );
130
130
}
131
131
132
- //tm.setSoTimeout(connectTimeout);
133
- //tm.setConnectionMonitors(connectionMonitors);
134
-
135
- state .tm .setTcpNoDelay (true );
136
- state .tm .serverInit (state );
132
+ state .tm .connect (state );
137
133
138
134
/* Wait until first KEX has finished */
139
135
@@ -142,7 +138,7 @@ public synchronized void connect(int timeout_milliseconds) throws IOException
142
138
143
139
/**
144
140
* Retrieve the underlying socket.
145
- *
141
+ *
146
142
* @return the socket that has been passed to the constructor.
147
143
*/
148
144
public Socket getSocket ()
@@ -160,7 +156,7 @@ public Socket getSocket()
160
156
* <p>
161
157
* Note: This implementation will never start automatically a key exchange (other than the initial one)
162
158
* unless you or the connected SSH-2 client ask for it.
163
- *
159
+ *
164
160
* @throws IOException
165
161
* In case of any failure behind the scenes.
166
162
*/
@@ -179,10 +175,10 @@ public synchronized void forceKeyExchange() throws IOException
179
175
/**
180
176
* Returns a {@link ConnectionInfo} object containing the details of
181
177
* the connection. May be called as soon as the first key exchange has been
182
- * started. The method blocks in case the first key exchange has not been completed.
178
+ * started. The method blocks in case the first key exchange has not been completed.
183
179
* <p>
184
180
* Note: upon return of this method, authentication may still be pending.
185
- *
181
+ *
186
182
* @return A {@link ConnectionInfo} object.
187
183
* @throws IOException
188
184
* In case of any failure behind the scenes; e.g., first key exchange was aborted.
@@ -201,12 +197,12 @@ public synchronized ConnectionInfo getConnectionInfo() throws IOException
201
197
202
198
/**
203
199
* Change the current DSA hostkey. Either a DSA or RSA private key must be set for a successful handshake with
204
- * the client.
200
+ * the client.
205
201
* <p>
206
202
* Note: You can change an existing DSA hostkey after the initial kex exchange (the new value will
207
203
* be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the
208
204
* current DSA key, otherwise the next key exchange may fail in case the client supports only DSA hostkeys.
209
- *
205
+ *
210
206
* @param dsa_hostkey
211
207
*/
212
208
public synchronized void setDsaHostKey (DSAPrivateKey dsa_hostkey )
@@ -223,12 +219,12 @@ public synchronized void setDsaHostKey(DSAPrivateKey dsa_hostkey)
223
219
224
220
/**
225
221
* Change the current RSA hostkey. Either a DSA or RSA private key must be set for a successful handshake with
226
- * the client.
222
+ * the client.
227
223
* <p>
228
224
* Note: You can change an existing RSA hostkey after the initial kex exchange (the new value will
229
225
* be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the
230
226
* current RSA key, otherwise the next key exchange may fail in case the client supports only RSA hostkeys.
231
- *
227
+ *
232
228
* @param rsa_hostkey
233
229
*/
234
230
public synchronized void setRsaHostKey (RSAPrivateKey rsa_hostkey )
@@ -246,8 +242,8 @@ public synchronized void setRsaHostKey(RSAPrivateKey rsa_hostkey)
246
242
/**
247
243
* Utility method that loads a PEM based hostkey (either RSA or DSA based) and
248
244
* calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>.
249
- *
250
- * @param pemfile The PEM data
245
+ *
246
+ * @param pemdata The PEM data
251
247
* @param password Password, may be null in case the PEM data is not password protected
252
248
* @throws IOException In case of any error.
253
249
*/
@@ -265,7 +261,7 @@ public void setPEMHostKey(char[] pemdata, String password) throws IOException
265
261
/**
266
262
* Utility method that loads a hostkey from a PEM file (either RSA or DSA based) and
267
263
* calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>.
268
- *
264
+ *
269
265
* @param pemFile The PEM file
270
266
* @param password Password, may be null in case the PEM file is not password protected
271
267
* @throws IOException
@@ -312,7 +308,7 @@ else if (next_rsa_key != null)
312
308
* generated by the client (e.g., client opens a new Session which results in a <code>ServerSession</code>).
313
309
* <p>
314
310
* Note: This must be set before the first handshake.
315
- *
311
+ *
316
312
* @param cb The callback implementation
317
313
*/
318
314
public synchronized void setServerConnectionCallback (ServerConnectionCallback cb )
@@ -327,7 +323,7 @@ public synchronized void setServerConnectionCallback(ServerConnectionCallback cb
327
323
* Callback interface with methods that will be called upon authentication events.
328
324
* <p>
329
325
* Note: This must be set before the first handshake.
330
- *
326
+ *
331
327
* @param cb The callback implementation
332
328
*/
333
329
public synchronized void setAuthenticationCallback (ServerAuthenticationCallback cb )
0 commit comments