Author: ggregory
Date: Tue Jan 15 01:37:55 2013
New Revision: 1433253

URL: http://svn.apache.org/viewvc?rev=1433253&view=rev
Log:
[VFS-451] Authentication fails using private key.

Modified:
    
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
    commons/proper/vfs/trunk/src/changes/changes.xml

Modified: 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java?rev=1433253&r1=1433252&r2=1433253&view=diff
==============================================================================
--- 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
 (original)
+++ 
commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpClientFactory.java
 Tue Jan 15 01:37:55 2013
@@ -85,7 +85,7 @@ public final class SftpClientFactory
             jsch.setIdentityRepository(repositoryFactory.create(jsch));
         }
 
-        addIdentities(jsch, sshDir, identities);
+        addIdentities(jsch, sshDir, identities, password);
 
         Session session;
         try
@@ -172,13 +172,13 @@ public final class SftpClientFactory
         return session;
     }
 
-    private static void addIdentities(final JSch jsch, final File sshDir, 
final File[] identities) throws FileSystemException
-    {
+    private static void addIdentities(final JSch jsch, final File sshDir, 
final File[] identities, char[] password) throws FileSystemException
+    {  
         if (identities != null)
         {
             for (final File privateKeyFile : identities)
             {
-                addIndentity(jsch, privateKeyFile);
+                addIndentity(jsch, privateKeyFile, password);
             }
         }
         else
@@ -187,16 +187,16 @@ public final class SftpClientFactory
             final File privateKeyFile = new File(sshDir, "id_rsa");
             if (privateKeyFile.isFile() && privateKeyFile.canRead())
             {
-                addIndentity(jsch, privateKeyFile);
+                addIndentity(jsch, privateKeyFile, password);
             }
         }
     }
 
-    private static void addIndentity(final JSch jsch, final File 
privateKeyFile) throws FileSystemException
+    private static void addIndentity(final JSch jsch, final File 
privateKeyFile, char[] password) throws FileSystemException
     {
         try
         {
-            jsch.addIdentity(privateKeyFile.getAbsolutePath());
+            jsch.addIdentity(privateKeyFile.getAbsolutePath(), password == 
null ? null : new String(password));
         }
         catch (final JSchException e)
         {

Modified: commons/proper/vfs/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/vfs/trunk/src/changes/changes.xml?rev=1433253&r1=1433252&r2=1433253&view=diff
==============================================================================
--- commons/proper/vfs/trunk/src/changes/changes.xml (original)
+++ commons/proper/vfs/trunk/src/changes/changes.xml Tue Jan 15 01:37:55 2013
@@ -26,6 +26,9 @@
 <!--       <action issue="VFS-443" dev="ggregory" type="update" 
due-to="nickallen"> -->
 <!--           [Local] Need an easy way to convert from a FileObject to a 
File. -->
 <!--       </action> -->
+      <action issue="VFS-451" dev="ggregory" type="fix" due-to="ilmarcoronchi">
+        Authentication fails using private key.
+      </action>
       <action issue="VFS-450" dev="ggregory" type="fix" due-to="dlmarion">
         HDFSFileSystem.resolveFile() does not honor CacheStrategy.ON_RESOLVE.
       </action>


Reply via email to