Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/ServerConnection.java @ 287:db9b028016de ganymed
start conversion from trilead to ganymed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 18 Jul 2014 19:52:08 -0700 |
parents | b4ca341c318d |
children | d2ee20d9dff1 |
comparison
equal
deleted
inserted
replaced
286:4656869af8fe | 287:db9b028016de |
---|---|
70 * | 70 * |
71 * @param s The socket | 71 * @param s The socket |
72 * @param dsa_key The DSA hostkey, may be <code>NULL</code> | 72 * @param dsa_key The DSA hostkey, may be <code>NULL</code> |
73 * @param rsa_key The RSA hostkey, may be <code>NULL</code> | 73 * @param rsa_key The RSA hostkey, may be <code>NULL</code> |
74 */ | 74 */ |
75 public ServerConnection(Socket s, DSAPrivateKey dsa_key, RSAPrivateKey rsa_key) | 75 public ServerConnection(Socket s, KeyPair dsa_key, KeyPair rsa_key) |
76 { | 76 { |
77 state.s = s; | 77 state.s = s; |
78 state.softwareversion = softwareversion; | 78 state.softwareversion = softwareversion; |
79 state.next_dsa_key = dsa_key; | 79 state.next_dsa_key = dsa_key; |
80 state.next_rsa_key = rsa_key; | 80 state.next_rsa_key = rsa_key; |
206 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the | 206 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the |
207 * current DSA key, otherwise the next key exchange may fail in case the client supports only DSA hostkeys. | 207 * current DSA key, otherwise the next key exchange may fail in case the client supports only DSA hostkeys. |
208 * | 208 * |
209 * @param dsa_hostkey | 209 * @param dsa_hostkey |
210 */ | 210 */ |
211 public synchronized void setDsaHostKey(DSAPrivateKey dsa_hostkey) | 211 public synchronized void setDsaHostKey(KeyPair dsa_hostkey) |
212 { | 212 { |
213 synchronized (state) | 213 synchronized (state) |
214 { | 214 { |
215 if ((dsa_hostkey == null) && (state.next_dsa_key != null) && (state.tm != null)) | 215 if ((dsa_hostkey == null) && (state.next_dsa_key != null) && (state.tm != null)) |
216 throw new IllegalStateException("Cannot remove DSA hostkey after first key exchange."); | 216 throw new IllegalStateException("Cannot remove DSA hostkey after first key exchange."); |
228 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the | 228 * be used during the next server initiated key exchange), but you cannot remove (i.e., set to <code>null</code>) the |
229 * current RSA key, otherwise the next key exchange may fail in case the client supports only RSA hostkeys. | 229 * current RSA key, otherwise the next key exchange may fail in case the client supports only RSA hostkeys. |
230 * | 230 * |
231 * @param rsa_hostkey | 231 * @param rsa_hostkey |
232 */ | 232 */ |
233 public synchronized void setRsaHostKey(RSAPrivateKey rsa_hostkey) | 233 public synchronized void setRsaHostKey(KeyPair rsa_hostkey) |
234 { | 234 { |
235 synchronized (state) | 235 synchronized (state) |
236 { | 236 { |
237 if ((rsa_hostkey == null) && (state.next_rsa_key != null) && (state.tm != null)) | 237 if ((rsa_hostkey == null) && (state.next_rsa_key != null) && (state.tm != null)) |
238 throw new IllegalStateException("Cannot remove RSA hostkey after first key exchange."); | 238 throw new IllegalStateException("Cannot remove RSA hostkey after first key exchange."); |
250 * @param password Password, may be null in case the PEM data is not password protected | 250 * @param password Password, may be null in case the PEM data is not password protected |
251 * @throws IOException In case of any error. | 251 * @throws IOException In case of any error. |
252 */ | 252 */ |
253 public void setPEMHostKey(char[] pemdata, String password) throws IOException | 253 public void setPEMHostKey(char[] pemdata, String password) throws IOException |
254 { | 254 { |
255 Object key = PEMDecoder.decode(pemdata, password); | 255 PrivateKey key = PEMDecoder.decode(pemdata, password).getPrivate(); |
256 | 256 |
257 if (key instanceof DSAPrivateKey) | 257 if (key instanceof DSAPrivateKey) |
258 setDsaHostKey((DSAPrivateKey) key); | 258 setDsaHostKey((DSAPrivateKey) key); |
259 | 259 |
260 if (key instanceof RSAPrivateKey) | 260 if (key instanceof RSAPrivateKey) |