Class SftpClientFactory

java.lang.Object
org.apache.commons.vfs2.provider.sftp.SftpClientFactory

public final class SftpClientFactory extends Object
Create a JSch Session instance.
  • Field Details

  • Constructor Details

    • SftpClientFactory

      private SftpClientFactory()
  • Method Details

    • addIdentities

      private static void addIdentities(com.jcraft.jsch.JSch jsch, File sshDir, IdentityProvider[] identities) throws FileSystemException
      Throws:
      FileSystemException
    • addIdentity

      private static void addIdentity(com.jcraft.jsch.JSch jsch, IdentityProvider identity) throws FileSystemException
      Throws:
      FileSystemException
    • createConnection

      public static com.jcraft.jsch.Session createConnection(String hostname, int port, char[] username, char[] password, FileSystemOptions fileSystemOptions) throws FileSystemException
      Creates a new connection to the server.
      Parameters:
      hostname - The name of the host to connect to.
      port - The port to use.
      username - The user's id.
      password - The user's password.
      fileSystemOptions - The FileSystem options.
      Returns:
      A Session, never null.
      Throws:
      FileSystemException - if an error occurs.
    • createProxyHTTP

      private static com.jcraft.jsch.ProxyHTTP createProxyHTTP(String proxyHost, int proxyPort)
    • createProxySOCKS5

      private static com.jcraft.jsch.ProxySOCKS5 createProxySOCKS5(String proxyHost, int proxyPort)
    • createStreamProxy

      private static com.jcraft.jsch.Proxy createStreamProxy(String proxyHost, int proxyPort, FileSystemOptions fileSystemOptions, SftpFileSystemConfigBuilder builder)
    • findSshDir

      private static File findSshDir()
      Finds the .ssh directory.

      The lookup order is:

      1. The system property vfs.sftp.sshdir (the override mechanism)
      2. user.home/.ssh
      3. On Windows only: C:\cygwin\home[user.name]\.ssh
      4. The current directory, as a last resort.

      Windows Notes

      The default installation directory for Cygwin is C:\cygwin. On my set up (Gary here), I have Cygwin in C:\bin\cygwin, not the default. Also, my .ssh directory was created in the user.home directory.

      Returns:
      The .ssh directory
    • setConfigRepository

      private static void setConfigRepository(com.jcraft.jsch.JSch jsch, File sshDir, com.jcraft.jsch.ConfigRepository configRepository, boolean loadOpenSSHConfig) throws FileSystemException
      Throws:
      FileSystemException
    • setKnownHosts

      private static void setKnownHosts(com.jcraft.jsch.JSch jsch, File sshDir, File knownHostsFile) throws FileSystemException
      Throws:
      FileSystemException