Class SftpClientFactory


  • public final class SftpClientFactory
    extends java.lang.Object
    Create a JSch Session instance.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  SftpClientFactory.JSchLogger
      Interface JSchLogger with JCL.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.commons.logging.Log LOG  
      private static java.lang.String OPENSSH_CONFIG_NAME  
      private static java.lang.String SSH_DIR_NAME  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SftpClientFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static void addIdentities​(com.jcraft.jsch.JSch jsch, java.io.File sshDir, IdentityProvider[] identities)  
      private static void addIdentity​(com.jcraft.jsch.JSch jsch, IdentityProvider identity)  
      static com.jcraft.jsch.Session createConnection​(java.lang.String hostname, int port, char[] username, char[] password, FileSystemOptions fileSystemOptions)
      Creates a new connection to the server.
      private static com.jcraft.jsch.ProxyHTTP createProxyHTTP​(java.lang.String proxyHost, int proxyPort)  
      private static com.jcraft.jsch.ProxySOCKS5 createProxySOCKS5​(java.lang.String proxyHost, int proxyPort)  
      private static com.jcraft.jsch.Proxy createStreamProxy​(java.lang.String proxyHost, int proxyPort, FileSystemOptions fileSystemOptions, SftpFileSystemConfigBuilder builder)  
      private static java.io.File findSshDir()
      Finds the .ssh directory.
      private static void setConfigRepository​(com.jcraft.jsch.JSch jsch, java.io.File sshDir, com.jcraft.jsch.ConfigRepository configRepository, boolean loadOpenSSHConfig)  
      private static void setKnownHosts​(com.jcraft.jsch.JSch jsch, java.io.File sshDir, java.io.File knownHostsFile)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OPENSSH_CONFIG_NAME

        private static final java.lang.String OPENSSH_CONFIG_NAME
        See Also:
        Constant Field Values
      • LOG

        private static final org.apache.commons.logging.Log LOG
    • Constructor Detail

      • SftpClientFactory

        private SftpClientFactory()
    • Method Detail

      • createConnection

        public static com.jcraft.jsch.Session createConnection​(java.lang.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​(java.lang.String proxyHost,
                                                                 int proxyPort)
      • createProxySOCKS5

        private static com.jcraft.jsch.ProxySOCKS5 createProxySOCKS5​(java.lang.String proxyHost,
                                                                     int proxyPort)
      • findSshDir

        private static java.io.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,
                                                java.io.File sshDir,
                                                com.jcraft.jsch.ConfigRepository configRepository,
                                                boolean loadOpenSSHConfig)
                                         throws FileSystemException
        Throws:
        FileSystemException