maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r189930 - /maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java
Date Fri, 10 Jun 2005 09:26:43 GMT
Author: brett
Date: Fri Jun 10 02:26:42 2005
New Revision: 189930

URL: http://svn.apache.org/viewcvs?rev=189930&view=rev
Log:
PR: MNG-465
o correctly pass private key and port to external app
o don't require a private key

Modified:
    maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java?rev=189930&r1=189929&r2=189930&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/sshext/ScpExternalWagon.java
Fri Jun 10 02:26:42 2005
@@ -22,7 +22,6 @@
 import org.apache.maven.wagon.TransferFailedException;
 import org.apache.maven.wagon.WagonConstants;
 import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
 import org.apache.maven.wagon.authorization.AuthorizationException;
 import org.apache.maven.wagon.events.TransferEvent;
 import org.apache.maven.wagon.repository.RepositoryPermissions;
@@ -33,9 +32,6 @@
 import org.codehaus.plexus.util.cli.Commandline;
 
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
 
 /**
  * SCP deployer using "external" scp program.  To allow for
@@ -49,8 +45,6 @@
     extends AbstractWagon
     implements SshCommandExecutor
 {
-    public static int DEFAULT_SSH_PORT = 22;
-
     /**
      * The external SCP command to use - default is <code>scp</code>.
      *
@@ -80,6 +74,10 @@
      */
     private String sshArgs = null;
 
+    private int port;
+
+    private File privateKey;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -92,12 +90,7 @@
             throw new IllegalArgumentException( "Authentication Credentials cannot be null
for SSH protocol" );
         }
 
-        int port = getRepository().getPort();
-
-        if ( port == WagonConstants.UNKNOWN_PORT )
-        {
-            port = DEFAULT_SSH_PORT;
-        }
+        port = getRepository().getPort();
 
         // If user don't define a password, he want to use a private key
         if ( authenticationInfo.getPassword() == null )
@@ -122,14 +115,7 @@
 
                 fireSessionDebug( "Using private key: " + privateKey );
 
-                // TODO: do something with it
-            }
-            else
-            {
-                String msg = "Private key was not found. You must define a private key or
a password for repo: " +
-                    getRepository().getName();
-
-                throw new AuthenticationException( msg );
+                this.privateKey = privateKey;
             }
         }
         // nothing to connect to
@@ -174,6 +160,24 @@
 
         cl.setExecutable( sshExecutable );
 
+        if ( privateKey != null )
+        {
+            cl.createArgument().setValue( "-i" );
+            cl.createArgument().setFile( privateKey );
+        }
+
+        if ( port != WagonConstants.UNKNOWN_PORT )
+        {
+            if ( sshExecutable.indexOf( "plink" ) >= 0 )
+            {
+                cl.createArgument().setLine( "-P " + port );
+            }
+            else
+            {
+                cl.createArgument().setLine( "-p " + port );
+            }
+        }
+
         if ( sshArgs != null )
         {
             cl.createArgument().setLine( sshArgs );
@@ -203,6 +207,17 @@
         cl.setWorkingDirectory( localFile.getParentFile().getAbsolutePath() );
 
         cl.setExecutable( scpExecutable );
+
+        if ( privateKey != null )
+        {
+            cl.createArgument().setValue( "-i" );
+            cl.createArgument().setFile( privateKey );
+        }
+
+        if ( port != WagonConstants.UNKNOWN_PORT )
+        {            
+            cl.createArgument().setLine( "-P " + port );
+        }
 
         if ( scpArgs != null )
         {



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


Mime
View raw message