maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject cvs commit: maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh ScpWagon.java
Date Wed, 21 Apr 2004 04:05:36 GMT
jvanzyl     2004/04/20 21:05:36

  Modified:    wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh
                        ScpWagon.java
  Log:
  o http://jira.codehaus.org/secure/ViewIssue.jspa?key=WAGONSSH-1
  
  Revision  Changes    Path
  1.2       +49 -18    maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java
  
  Index: ScpWagon.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-providers/ssh/src/main/java/org/apache/maven/wagon/providers/ssh/ScpWagon.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ScpWagon.java	30 Mar 2004 14:43:07 -0000	1.1
  +++ ScpWagon.java	21 Apr 2004 04:05:36 -0000	1.2
  @@ -66,6 +66,10 @@
   
       protected Session session = null;
   
  +    // ----------------------------------------------------------------------
  +    //
  +    // ----------------------------------------------------------------------
  +
       public void openConnection()
           throws Exception
       {
  @@ -91,32 +95,38 @@
   
               session = jsch.getSession( authInfo.getUserName(), host, port );
   
  -            // Look for the private key and use it if available.
  +            File privateKey;
  +
               if ( authInfo.getPrivateKey() != null )
               {
  -                File privateKey = new File( authInfo.getPrivateKey() );
  +                privateKey = new File( authInfo.getPrivateKey() );
  +            }
  +            else
  +            {
  +                privateKey = findPrivateKey();
  +            }
   
  -                if ( privateKey.exists() )
  +            if ( privateKey.exists() )
  +            {
  +                if ( authInfo.getPassphrase() == null )
                   {
  -                    if ( authInfo.getPassphrase() == null )
  -                    {
  -                        String msg = "Private key provided " + "without passphrase for
repo: " + getRepository().getName();
  +                    String msg = "Private key provided " + "without passphrase for repo:
" + getRepository().getName();
   
  -                        throw new AuthenticationException( msg );
  -                    }
  +                    throw new AuthenticationException( msg );
  +                }
   
  -                    fireSessionDebug( "Using private key: " + privateKey );
  +                fireSessionDebug( "Using private key: " + privateKey );
   
  -                    jsch.addIdentity( privateKey.getAbsolutePath(), authInfo.getPassphrase()
);
  -                }
  -                else
  -                {
  -                    String msg = "Private key: " + privateKey + " not found ";
  +                jsch.addIdentity( privateKey.getAbsolutePath(), authInfo.getPassphrase()
);
  +            }
  +            else
  +            {
  +                String msg = "Private key: " + privateKey + " not found ";
   
  -                    throw new AuthenticationException( msg );
  -                }
  +                throw new AuthenticationException( msg );
               }
   
  +
               ProxyInfo proxyInfo = getRepository().getProxyInfo();
   
               if ( proxyInfo != null && proxyInfo.getHost() != null )
  @@ -149,7 +159,6 @@
               session.setUserInfo( ui );
   
               session.connect();
  -
           }
           catch ( Exception e )
           {
  @@ -158,6 +167,28 @@
               throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(),
e );
           }
       }
  +
  +    // ----------------------------------------------------------------------
  +    //
  +    // ----------------------------------------------------------------------
  +
  +    private File findPrivateKey()
  +    {
  +        String privateKeyDirectory = System.getProperty( "wagon.privateKeyDirectory" );
  +
  +        if ( privateKeyDirectory == null )
  +        {
  +            privateKeyDirectory = System.getProperty( "user.home" );
  +        }
  +
  +        File privateKey = new File( privateKeyDirectory, ".ssh/id_dsa" );
  +
  +        return privateKey;
  +    }
  +
  +    // ----------------------------------------------------------------------
  +    //
  +    // ----------------------------------------------------------------------
   
       public void closeConnection()
           throws Exception
  
  
  

---------------------------------------------------------------------
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