changeset 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 5824a1475be4
children 9ae4ed7bb523
files src/ch/ethz/ssh2/Connection.java src/ch/ethz/ssh2/ServerConnection.java src/ch/ethz/ssh2/channel/ChannelManager.java
diffstat 3 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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.
+     * <p>
+     * At the moment, only HTTP proxies are supported.
+     * <p>
+     * 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 <code>null</code>,
+     *            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
--- 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" };
--- 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;
         }