1616import ch .ethz .ssh2 .server .ServerConnectionState ;
1717import ch .ethz .ssh2 .signature .DSAPrivateKey ;
1818import ch .ethz .ssh2 .signature .RSAPrivateKey ;
19- import ch .ethz .ssh2 .transport .TransportManager ;
19+ import ch .ethz .ssh2 .transport .ServerTransportManager ;
2020
2121/**
2222 * A server-side SSH-2 connection.
23- *
23+ *
2424 * @author Christian
2525 *
2626 */
@@ -39,9 +39,9 @@ public class ServerConnection
3939 * <p>
4040 * Note: you need to call {@link #connect()} or {@link #connect(int)} to
4141 * perform the initial handshake and establish the encrypted communication.
42- *
42+ *
4343 * @see #connect(int)
44- *
44+ *
4545 * @param s The socket
4646 */
4747 public ServerConnection (Socket s )
@@ -62,9 +62,9 @@ public ServerConnection(Socket s, String softwareversion) {
6262 * perform the initial handshake and establish the encrypted communication.
6363 * <p>
6464 * Please read the javadoc for the {@link #connect(int)} method.
65- *
65+ *
6666 * @see #connect(int)
67- *
67+ *
6868 * @param s The socket
6969 * @param dsa_key The DSA hostkey, may be <code>NULL</code>
7070 * @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)
8484 * Note: this is a wrapper that calls <code>connect(0)</code> (i.e., connect with no timeout).
8585 * <p>
8686 * Please read the javadoc for the {@link #connect(int)} method.
87- *
87+ *
8888 * @see #connect(int)
89- *
89+ *
9090 * @throws IOException
9191 */
9292 public synchronized void connect () throws IOException
@@ -101,12 +101,12 @@ public synchronized void connect() throws IOException
101101 * <p>
102102 * Note 2: You must set the callbacks for authentication ({@link #setAuthenticationCallback(ServerAuthenticationCallback)})
103103 * and connection events ({@link #setServerConnectionCallback(ServerConnectionCallback)}).
104- *
104+ *
105105 * @see #setPEMHostKey(char[], String)
106106 * @see #setPEMHostKey(File, String)
107107 * @see #setRsaHostKey(RSAPrivateKey)
108108 * @see #setDsaHostKey(DSAPrivateKey)
109- *
109+ *
110110 * @param timeout_milliseconds Timeout in milliseconds, <code>0</code> means no timeout.
111111 * @throws IOException
112112 */
@@ -126,14 +126,10 @@ public synchronized void connect(int timeout_milliseconds) throws IOException
126126 if ((state .next_dsa_key == null ) && (state .next_rsa_key == null ))
127127 throw new IllegalStateException ("Neither a RSA nor a DSA host key has been specified!" );
128128
129- state .tm = new TransportManager ( );
129+ state .tm = new ServerTransportManager ( state . s );
130130 }
131131
132- //tm.setSoTimeout(connectTimeout);
133- //tm.setConnectionMonitors(connectionMonitors);
134-
135- state .tm .setTcpNoDelay (true );
136- state .tm .serverInit (state );
132+ state .tm .connect (state );
137133
138134 /* Wait until first KEX has finished */
139135
@@ -142,7 +138,7 @@ public synchronized void connect(int timeout_milliseconds) throws IOException
142138
143139 /**
144140 * Retrieve the underlying socket.
145- *
141+ *
146142 * @return the socket that has been passed to the constructor.
147143 */
148144 public Socket getSocket ()
@@ -160,7 +156,7 @@ public Socket getSocket()
160156 * <p>
161157 * Note: This implementation will never start automatically a key exchange (other than the initial one)
162158 * unless you or the connected SSH-2 client ask for it.
163- *
159+ *
164160 * @throws IOException
165161 * In case of any failure behind the scenes.
166162 */
@@ -179,10 +175,10 @@ public synchronized void forceKeyExchange() throws IOException
179175 /**
180176 * Returns a {@link ConnectionInfo} object containing the details of
181177 * 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.
183179 * <p>
184180 * Note: upon return of this method, authentication may still be pending.
185- *
181+ *
186182 * @return A {@link ConnectionInfo} object.
187183 * @throws IOException
188184 * 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
201197
202198 /**
203199 * 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.
205201 * <p>
206202 * Note: You can change an existing DSA hostkey after the initial kex exchange (the new value will
207203 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the
208204 * current DSA key, otherwise the next key exchange may fail in case the client supports only DSA hostkeys.
209- *
205+ *
210206 * @param dsa_hostkey
211207 */
212208 public synchronized void setDsaHostKey (DSAPrivateKey dsa_hostkey )
@@ -223,12 +219,12 @@ public synchronized void setDsaHostKey(DSAPrivateKey dsa_hostkey)
223219
224220 /**
225221 * 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.
227223 * <p>
228224 * Note: You can change an existing RSA hostkey after the initial kex exchange (the new value will
229225 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the
230226 * current RSA key, otherwise the next key exchange may fail in case the client supports only RSA hostkeys.
231- *
227+ *
232228 * @param rsa_hostkey
233229 */
234230 public synchronized void setRsaHostKey (RSAPrivateKey rsa_hostkey )
@@ -246,8 +242,8 @@ public synchronized void setRsaHostKey(RSAPrivateKey rsa_hostkey)
246242 /**
247243 * Utility method that loads a PEM based hostkey (either RSA or DSA based) and
248244 * calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>.
249- *
250- * @param pemfile The PEM data
245+ *
246+ * @param pemdata The PEM data
251247 * @param password Password, may be null in case the PEM data is not password protected
252248 * @throws IOException In case of any error.
253249 */
@@ -265,7 +261,7 @@ public void setPEMHostKey(char[] pemdata, String password) throws IOException
265261 /**
266262 * Utility method that loads a hostkey from a PEM file (either RSA or DSA based) and
267263 * calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>.
268- *
264+ *
269265 * @param pemFile The PEM file
270266 * @param password Password, may be null in case the PEM file is not password protected
271267 * @throws IOException
@@ -312,7 +308,7 @@ else if (next_rsa_key != null)
312308 * generated by the client (e.g., client opens a new Session which results in a <code>ServerSession</code>).
313309 * <p>
314310 * Note: This must be set before the first handshake.
315- *
311+ *
316312 * @param cb The callback implementation
317313 */
318314 public synchronized void setServerConnectionCallback (ServerConnectionCallback cb )
@@ -327,7 +323,7 @@ public synchronized void setServerConnectionCallback(ServerConnectionCallback cb
327323 * Callback interface with methods that will be called upon authentication events.
328324 * <p>
329325 * Note: This must be set before the first handshake.
330- *
326+ *
331327 * @param cb The callback implementation
332328 */
333329 public synchronized void setAuthenticationCallback (ServerAuthenticationCallback cb )
0 commit comments