# HG changeset patch # User Carl Byington # Date 1405739873 25200 # Node ID d2ee20d9dff1aa9e40da4f0d6b1b65f71db0b772 # Parent 5824a1475be41dbfb6edbac851a60ad716b524f9 start conversion from trilead to ganymed diff -r 5824a1475be4 -r d2ee20d9dff1 src/ch/ethz/ssh2/Connection.java --- a/src/ch/ethz/ssh2/Connection.java Fri Jul 18 19:59:32 2014 -0700 +++ b/src/ch/ethz/ssh2/Connection.java Fri Jul 18 20:17:53 2014 -0700 @@ -1253,6 +1253,29 @@ } /** + * Used to tell the library that the connection shall be established through + * a proxy server. It only makes sense to call this method before calling + * the {@link #connect() connect()} method. + *

+ * At the moment, only HTTP proxies are supported. + *

+ * Note: This method can be called any number of times. The + * {@link #connect() connect()} method will use the value set in the last + * preceding invocation of this method. + * + * @see HTTPProxyData + * + * @param proxy + * Connection information about the proxy. If null, + * then no proxy will be used (non surprisingly, this is also the + * default). + */ + + public synchronized void setProxyData(HTTPProxyData proxy) { + this.proxy = proxy; + } + + /** * Request a remote port forwarding. * If successful, then forwarded connections will be redirected to the given target address. * You can cancle a requested remote port forwarding by calling diff -r 5824a1475be4 -r d2ee20d9dff1 src/ch/ethz/ssh2/ServerConnection.java --- a/src/ch/ethz/ssh2/ServerConnection.java Fri Jul 18 19:59:32 2014 -0700 +++ b/src/ch/ethz/ssh2/ServerConnection.java Fri Jul 18 20:17:53 2014 -0700 @@ -252,13 +252,12 @@ */ public void setPEMHostKey(char[] pemdata, String password) throws IOException { - PrivateKey key = PEMDecoder.decode(pemdata, password).getPrivate(); + KeyPair pair = PEMDecoder.decode(pemdata, password); + PrivateKey key = pair.getPrivate(); - if (key instanceof DSAPrivateKey) - setDsaHostKey((DSAPrivateKey) key); + if (key instanceof DSAPrivateKey) setDsaHostKey(pair); - if (key instanceof RSAPrivateKey) - setRsaHostKey((RSAPrivateKey) key); + if (key instanceof RSAPrivateKey) setRsaHostKey(pair); } /** @@ -293,8 +292,7 @@ setPEMHostKey(cw.toCharArray(), password); } - private void fixCryptoWishList(CryptoWishList next_cryptoWishList, DSAPrivateKey next_dsa_key, - RSAPrivateKey next_rsa_key) + private void fixCryptoWishList(CryptoWishList next_cryptoWishList, KeyPair next_dsa_key, KeyPair next_rsa_key) { if ((next_dsa_key != null) && (next_rsa_key != null)) next_cryptoWishList.serverHostKeyAlgorithms = new String[] { "ssh-rsa", "ssh-dss" }; diff -r 5824a1475be4 -r d2ee20d9dff1 src/ch/ethz/ssh2/channel/ChannelManager.java --- a/src/ch/ethz/ssh2/channel/ChannelManager.java Fri Jul 18 19:59:32 2014 -0700 +++ b/src/ch/ethz/ssh2/channel/ChannelManager.java Fri Jul 18 20:17:53 2014 -0700 @@ -12,6 +12,7 @@ import java.util.List; import java.util.Map; +import ch.ethz.ssh2.AuthAgentCallback; import ch.ethz.ssh2.ChannelCondition; import ch.ethz.ssh2.PacketFormatException; import ch.ethz.ssh2.PacketTypeException; @@ -466,7 +467,7 @@ * @param agent * @throws IOException */ - public boolean requestChannelAgentForwarding(Channel c, AuthAgentCallback authAgent) throws IOException { + public void requestChannelAgentForwarding(Channel c, AuthAgentCallback authAgent) throws IOException { synchronized (this) { if (this.authAgent != null) throw new IllegalStateException("Auth agent already exists"); @@ -481,9 +482,17 @@ log.debug("Requesting agent forwarding"); PacketChannelAuthAgentReq aar = new PacketChannelAuthAgentReq(c.remoteID); - tm.sendMessage(aar.getPayload()); + synchronized(c.channelSendLock) { + if (c.closeMessageSent) { + throw c.getReasonClosed(); + } + tm.sendMessage(aar.getPayload()); + } - if (waitForChannelRequestResult(c) == false) { + try { + waitForChannelSuccessOrFailure(c); + } + catch(IOException e) { authAgent = null; return false; }