comparison src/ch/ethz/ssh2/ServerConnection.java @ 289:d2ee20d9dff1 ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 20:17:53 -0700
parents db9b028016de
children ab3a99f11a36
comparison
equal deleted inserted replaced
288:5824a1475be4 289:d2ee20d9dff1
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 PrivateKey key = PEMDecoder.decode(pemdata, password).getPrivate(); 255 KeyPair pair = PEMDecoder.decode(pemdata, password);
256 256 PrivateKey key = pair.getPrivate();
257 if (key instanceof DSAPrivateKey) 257
258 setDsaHostKey((DSAPrivateKey) key); 258 if (key instanceof DSAPrivateKey) setDsaHostKey(pair);
259 259
260 if (key instanceof RSAPrivateKey) 260 if (key instanceof RSAPrivateKey) setRsaHostKey(pair);
261 setRsaHostKey((RSAPrivateKey) key);
262 } 261 }
263 262
264 /** 263 /**
265 * Utility method that loads a hostkey from a PEM file (either RSA or DSA based) and 264 * Utility method that loads a hostkey from a PEM file (either RSA or DSA based) and
266 * calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>. 265 * calls either <code>setRsaHostKey()</code> or <code>setDsaHostKey()</code>.
291 fr.close(); 290 fr.close();
292 291
293 setPEMHostKey(cw.toCharArray(), password); 292 setPEMHostKey(cw.toCharArray(), password);
294 } 293 }
295 294
296 private void fixCryptoWishList(CryptoWishList next_cryptoWishList, DSAPrivateKey next_dsa_key, 295 private void fixCryptoWishList(CryptoWishList next_cryptoWishList, KeyPair next_dsa_key, KeyPair next_rsa_key)
297 RSAPrivateKey next_rsa_key)
298 { 296 {
299 if ((next_dsa_key != null) && (next_rsa_key != null)) 297 if ((next_dsa_key != null) && (next_rsa_key != null))
300 next_cryptoWishList.serverHostKeyAlgorithms = new String[] { "ssh-rsa", "ssh-dss" }; 298 next_cryptoWishList.serverHostKeyAlgorithms = new String[] { "ssh-rsa", "ssh-dss" };
301 else if (next_dsa_key != null) 299 else if (next_dsa_key != null)
302 next_cryptoWishList.serverHostKeyAlgorithms = new String[] { "ssh-dss" }; 300 next_cryptoWishList.serverHostKeyAlgorithms = new String[] { "ssh-dss" };