maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r660375 - in /maven/wagon/trunk: pom.xml wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
Date Tue, 27 May 2008 04:50:26 GMT
Author: brett
Date: Mon May 26 21:50:20 2008
New Revision: 660375

URL: http://svn.apache.org/viewvc?rev=660375&view=rev
Log:
[WAGON-172] add proxy support to SSH connections
Submitted by: Gilles Scokart (applied with modifications)

Modified:
    maven/wagon/trunk/pom.xml
    maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
    maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java

Modified: maven/wagon/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/pom.xml?rev=660375&r1=660374&r2=660375&view=diff
==============================================================================
--- maven/wagon/trunk/pom.xml (original)
+++ maven/wagon/trunk/pom.xml Mon May 26 21:50:20 2008
@@ -258,5 +258,8 @@
     <contributor>
       <name>Jochen Wiedmann</name>
     </contributor>
+    <contributor>
+      <name>Gilles Scokart</name>
+    </contributor>
   </contributors>
 </project>

Modified: maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java?rev=660375&r1=660374&r2=660375&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
(original)
+++ maven/wagon/trunk/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
Mon May 26 21:50:20 2008
@@ -132,7 +132,14 @@
         {
             public ProxyInfo getProxyInfo( String protocol )
             {
-                return proxy;
+                if ( proxy.getType().equalsIgnoreCase( protocol ) )
+                {
+                    return proxy;
+                }
+                else
+                {
+                    return null;
+                }
             }
         } );
     }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java?rev=660375&r1=660374&r2=660375&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
Mon May 26 21:50:20 2008
@@ -19,17 +19,14 @@
  * under the License.
  */
 
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.HostKey;
-import com.jcraft.jsch.HostKeyRepository;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Proxy;
-import com.jcraft.jsch.ProxyHTTP;
-import com.jcraft.jsch.ProxySOCKS5;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UIKeyboardInteractive;
-import com.jcraft.jsch.UserInfo;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Properties;
 
 import org.apache.maven.wagon.CommandExecutionException;
 import org.apache.maven.wagon.Streams;
@@ -47,14 +44,17 @@
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringInputStream;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Properties;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.HostKey;
+import com.jcraft.jsch.HostKeyRepository;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Proxy;
+import com.jcraft.jsch.ProxyHTTP;
+import com.jcraft.jsch.ProxySOCKS5;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UIKeyboardInteractive;
+import com.jcraft.jsch.UserInfo;
 
 /**
  * AbstractJschWagon 
@@ -125,32 +125,42 @@
             throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
         }
 
-        // TODO: should the protocol be http? Can then use SOCKS5 has a protocol also. If
so, retain "scp" for backwards compat
-        ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost()
);
+        Proxy proxy = null;
+        ProxyInfo proxyInfo = getProxyInfo( ProxyInfo.PROXY_SOCKS5, getRepository().getHost()
);
         if ( proxyInfo != null && proxyInfo.getHost() != null )
         {
-            Proxy proxy;
-
-            int proxyPort = proxyInfo.getPort();
-
-            // HACK: if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP Proxy
-            if ( proxyPort == SOCKS5_PROXY_PORT )
+            proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort() );
+            ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+        }
+        else
+        {
+            proxyInfo = getProxyInfo( ProxyInfo.PROXY_HTTP, getRepository().getHost() );
+            if ( proxyInfo != null && proxyInfo.getHost() != null )
             {
-                proxy = new ProxySOCKS5( proxyInfo.getHost() );
-                ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+                proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
+                ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
             }
             else
             {
-                proxy = new ProxyHTTP( proxyInfo.getHost(), proxyPort );
-                ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+                // Backwards compatibility
+                proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost()
);
+                if ( proxyInfo != null && proxyInfo.getHost() != null )
+                {
+                    // if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP
Proxy
+                    if ( proxyInfo.getPort() == SOCKS5_PROXY_PORT )
+                    {
+                        proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort()
);
+                        ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+                    }
+                    else
+                    {
+                        proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
+                        ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword()
);
+                    }
+                }
             }
-
-            session.setProxy( proxy );
-        }
-        else
-        {
-            session.setProxy( null );
         }
+        session.setProxy( proxy );
 
         // username and password will be given via UserInfo interface.
         UserInfo ui = new WagonUserInfo( authenticationInfo, getInteractiveUserInfo() );



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message