Class SftpClientFactory
- java.lang.Object
-
- org.apache.commons.vfs2.provider.sftp.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)
-
-
-
Field Detail
-
SSH_DIR_NAME
private static final java.lang.String SSH_DIR_NAME
- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
addIdentities
private static void addIdentities(com.jcraft.jsch.JSch jsch, java.io.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(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)
-
createStreamProxy
private static com.jcraft.jsch.Proxy createStreamProxy(java.lang.String proxyHost, int proxyPort, FileSystemOptions fileSystemOptions, SftpFileSystemConfigBuilder builder)
-
findSshDir
private static java.io.File findSshDir()
Finds the.ssh
directory.The lookup order is:
- The system property
vfs.sftp.sshdir
(the override mechanism) user.home
/.ssh- On Windows only:
C:\cygwin\home[user.name]\.ssh
- 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 inC:\bin\cygwin
, not the default. Also, my .ssh directory was created in theuser.home
directory.- Returns:
- The
.ssh
directory
- The system property
-
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
-
setKnownHosts
private static void setKnownHosts(com.jcraft.jsch.JSch jsch, java.io.File sshDir, java.io.File knownHostsFile) throws FileSystemException
- Throws:
FileSystemException
-
-