commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r159812 - in jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs: Resources.properties provider/sftp/SftpClientFactory.java provider/sftp/SftpFileSystem.java provider/sftp/SftpFileSystemConfigBuilder.java
Date Sat, 02 Apr 2005 21:03:01 GMT
Author: imario
Date: Sat Apr  2 13:03:01 2005
New Revision: 159812

URL: http://svn.apache.org/viewcvs?view=rev&rev=159812
Log:
sftp: moved configure of compression to its correct place
sftp: added "StrictHostKeyChecking" - possible values yes/no/ask

Submitted by: Thomas Kalbitz

Thanks!

Modified:
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
    jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties?view=diff&r1=159811&r2=159812
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
Sat Apr  2 13:03:01 2005
@@ -222,6 +222,7 @@
 vfs.provider.sftp/config-sshdir.error=SSH-Folder "{0}" non existent or not a folder.
 vfs.provider.sftp/unknown-modtime.error=Last modification time not fetched.
 vfs.provider.sftp/known-hosts.error=Error during processing known-hosts file "{0}".
+vfs.provider.sftp/StrictHostKeyChecking-arg.error=Illegal argument "{0}" hostKeyChecking
can only be "ask", "yes" or "no"
 
 # Ant tasks
 vfs.tasks/sync.no-destination.error=No destination file or directory specified.

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java?view=diff&r1=159811&r2=159812
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpClientFactory.java
Sat Apr  2 13:03:01 2005
@@ -24,6 +24,7 @@
 import org.apache.commons.vfs.util.Os;
 
 import java.io.File;
+import java.util.Properties;
 
 /**
  * Create a HttpClient instance
@@ -125,14 +126,37 @@
         try
         {
             session = jsch.getSession(username,
-                hostname,
-                port);
+                    hostname,
+                    port);
             session.setPassword(password);
 
             UserInfo userInfo = SftpFileSystemConfigBuilder.getInstance().getUserInfo(fileSystemOptions);
             if (userInfo != null)
             {
                 session.setUserInfo(userInfo);
+            }
+
+            Properties config = new Properties();
+
+            //set StrictHostKeyChecking property
+            String strictHostKeyChecking = SftpFileSystemConfigBuilder.getInstance().getStrictHostKeyChecking(fileSystemOptions);
+            if (strictHostKeyChecking != null)
+            {
+                config.setProperty("StrictHostKeyChecking", strictHostKeyChecking);
+            }
+
+            //set compression property
+            String compression = SftpFileSystemConfigBuilder.getInstance().getCompression(fileSystemOptions);
+            if (compression != null)
+            {
+                config.setProperty("compression.s2c", strictHostKeyChecking);
+                config.setProperty("compression.c2s", strictHostKeyChecking);
+            }
+
+            //set properties for the session
+            if (config.size() > 0)
+            {
+                session.setConfig(config);
             }
 
             session.connect();

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java?view=diff&r1=159811&r2=159812
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
Sat Apr  2 13:03:01 2005
@@ -28,7 +28,6 @@
 
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Hashtable;
 
 /**
  * Represents the files on an SFTP server.
@@ -85,24 +84,6 @@
                     rootName.getUserName(),
                     rootName.getPassword(),
                     getFileSystemOptions());
-
-                Hashtable config = null;
-
-                String compression = SftpFileSystemConfigBuilder.getInstance().getCompression(getFileSystemOptions());
-                if (compression != null)
-                {
-                    if (config == null)
-                    {
-                        config = new Hashtable();
-                    }
-                    config.put("compression.c2s", compression);
-                    config.put("compression.s2c", compression);
-                }
-
-                if (config != null)
-                {
-                    session.setConfig(config);
-                }
             }
             catch (final Exception e)
             {

Modified: jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java?view=diff&r1=159811&r2=159812
==============================================================================
--- jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
(original)
+++ jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystemConfigBuilder.java
Sat Apr  2 13:03:01 2005
@@ -131,6 +131,35 @@
         return (File[]) getParam(opts, "identities");
     }
 
+    /**
+     * configure the host key checking to use.<br>
+     * valid arguments are only yes, no and ask.<br>
+     * See the jsch documentation for details.
+     *
+     * @param opts
+     * @param hostKeyChecking
+     * @throws FileSystemException
+     */
+    public void setStrictHostKeyChecking(FileSystemOptions opts, String hostKeyChecking)
throws FileSystemException
+    {
+        if (hostKeyChecking == null || (!hostKeyChecking.equals("ask") && !hostKeyChecking.equals("no")
&& !hostKeyChecking.equals("yes")))
+        {
+            throw new FileSystemException("vfs.provider.sftp/StrictHostKeyChecking-arg.error",
hostKeyChecking);
+        }
+
+        setParam(opts, "StrictHostKeyChecking", hostKeyChecking);
+    }
+
+    /**
+     * @param opts
+     * @return the option value
+     * @see #setStrictHostKeyChecking(FileSystemOptions, String)
+     */
+    public String getStrictHostKeyChecking(FileSystemOptions opts)
+    {
+        return (String) getParam(opts, "StrictHostKeyChecking");
+    }
+
     protected Class getConfigClass()
     {
         return SftpFileSystem.class;



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message