Class SftpFileSystemConfigBuilder
- java.lang.Object
-
- org.apache.commons.vfs2.FileSystemConfigBuilder
-
- org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder
-
public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder
The config builder for various SFTP configuration options.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SftpFileSystemConfigBuilder.ProxyType
Proxy type.
-
Field Summary
Fields Modifier and Type Field Description static SftpFileSystemConfigBuilder.ProxyType
PROXY_HTTP
HTTP Proxy.static SftpFileSystemConfigBuilder.ProxyType
PROXY_SOCKS5
SOCKS Proxy.static SftpFileSystemConfigBuilder.ProxyType
PROXY_STREAM
Connects to the SFTP server through a remote host reached by SSH.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String
getCompression(FileSystemOptions opts)
protected java.lang.Class<? extends FileSystem>
getConfigClass()
Get the target of this configuration.java.lang.String
getFileNameEncoding(FileSystemOptions opts)
Gets the file name encoding.java.io.File[]
getIdentities(FileSystemOptions opts)
Deprecated.As of 2.1 usegetIdentityInfo(FileSystemOptions)
IdentityInfo[]
getIdentityInfo(FileSystemOptions opts)
Gets the identity info.IdentityRepositoryFactory
getIdentityRepositoryFactory(FileSystemOptions opts)
Get the identity repository factory.static SftpFileSystemConfigBuilder
getInstance()
Gets the singleton builder.java.io.File
getKnownHosts(FileSystemOptions opts)
java.lang.String
getPreferredAuthentications(FileSystemOptions opts)
Gets authentication order.java.lang.String
getProxyCommand(FileSystemOptions opts)
Gets the command that will be run on the proxy host when using a SftpStreamProxy.java.lang.String
getProxyHost(FileSystemOptions opts)
Gets the proxy to use for the SFTP connection.FileSystemOptions
getProxyOptions(FileSystemOptions opts)
Gets the proxy options that are used to connect to the proxy host.java.lang.String
getProxyPassword(FileSystemOptions opts)
Gets the proxy password that are used to connect to the proxy host.int
getProxyPort(FileSystemOptions opts)
Gets the proxy-port to use for the SFTP the connection.SftpFileSystemConfigBuilder.ProxyType
getProxyType(FileSystemOptions opts)
Gets the proxy type to use for the SFTP connection.java.lang.String
getProxyUser(FileSystemOptions opts)
Gets the user name for the proxy used for the SFTP connection.java.lang.String
getStrictHostKeyChecking(FileSystemOptions opts)
java.lang.Integer
getTimeout(FileSystemOptions opts)
java.lang.Boolean
getUserDirIsRoot(FileSystemOptions opts)
ReturnsBoolean.TRUE
if VFS should treat the user directory as the root directory.com.jcraft.jsch.UserInfo
getUserInfo(FileSystemOptions opts)
void
setCompression(FileSystemOptions opts, java.lang.String compression)
Configures the compression algorithms to use.void
setFileNameEncoding(FileSystemOptions opts, java.lang.String fileNameEncoding)
Sets the file name encoding.void
setIdentities(FileSystemOptions opts, java.io.File... identityFiles)
Deprecated.As of 2.1 usesetIdentityInfo(FileSystemOptions, IdentityInfo...)
void
setIdentityInfo(FileSystemOptions opts, IdentityInfo... identites)
Sets the identity info (your private key files).void
setIdentityRepositoryFactory(FileSystemOptions opts, IdentityRepositoryFactory factory)
Set the identity repository.void
setKnownHosts(FileSystemOptions opts, java.io.File knownHosts)
Sets the known_hosts file.void
setPreferredAuthentications(FileSystemOptions opts, java.lang.String preferredAuthentications)
Configures authentication order.void
setProxyCommand(FileSystemOptions opts, java.lang.String proxyCommand)
Sets the proxy username to use for the SFTP connection.void
setProxyHost(FileSystemOptions opts, java.lang.String proxyHost)
Sets the proxy to use for the SFTP connection.void
setProxyOptions(FileSystemOptions opts, FileSystemOptions proxyOptions)
Sets the proxy username to use for the SFTP connection.void
setProxyPassword(FileSystemOptions opts, java.lang.String proxyPassword)
Sets the proxy password to use for the SFTP connection.void
setProxyPort(FileSystemOptions opts, int proxyPort)
Sets the proxy port to use for the SFTP connection.void
setProxyType(FileSystemOptions opts, SftpFileSystemConfigBuilder.ProxyType proxyType)
Sets the proxy type to use for the SFTP connection.void
setProxyUser(FileSystemOptions opts, java.lang.String proxyUser)
Sets the proxy username to use for the SFTP connection.void
setStrictHostKeyChecking(FileSystemOptions opts, java.lang.String hostKeyChecking)
Configures the host key checking to use.void
setTimeout(FileSystemOptions opts, java.lang.Integer timeout)
Sets the timeout value on Jsch session.void
setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
Sets the whether to use the user directory as root (do not change to file system root).void
setUserInfo(FileSystemOptions opts, com.jcraft.jsch.UserInfo info)
Sets the Jsch UserInfo class to use.-
Methods inherited from class org.apache.commons.vfs2.FileSystemConfigBuilder
getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCharacter, getCharacter, getCharacter, getDouble, getDouble, getDouble, getEnum, getEnum, getFloat, getFloat, getFloat, getInteger, getInteger, getInteger, getLong, getLong, getLong, getParam, getRootURI, getShort, getShort, getShort, getString, getString, hasObject, hasParam, setParam, setParam, setRootURI
-
-
-
-
Field Detail
-
PROXY_HTTP
public static final SftpFileSystemConfigBuilder.ProxyType PROXY_HTTP
HTTP Proxy.
-
PROXY_SOCKS5
public static final SftpFileSystemConfigBuilder.ProxyType PROXY_SOCKS5
SOCKS Proxy.
-
PROXY_STREAM
public static final SftpFileSystemConfigBuilder.ProxyType PROXY_STREAM
Connects to the SFTP server through a remote host reached by SSH.On this proxy host, a command (e.g. SftpStreamProxy.NETCAT_COMMAND or SftpStreamProxy.NETCAT_COMMAND) is run to forward input/output streams between the target host and the VFS host.
When used, the proxy username (setProxyUser(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)) and hostname (setProxyHost(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)) must be set. Optionnaly, the command (setProxyCommand(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)), password (setProxyPassword(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)) and connection options (setProxyOptions(org.apache.commons.vfs2.FileSystemOptions, org.apache.commons.vfs2.FileSystemOptions)) can be set.
-
-
Method Detail
-
getInstance
public static SftpFileSystemConfigBuilder getInstance()
Gets the singleton builder.- Returns:
- the singleton builder.
-
getCompression
public java.lang.String getCompression(FileSystemOptions opts)
- Parameters:
opts
- The FileSystem options.- Returns:
- The names of the compression algorithms, comma-separated.
- See Also:
setCompression(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)
-
getConfigClass
protected java.lang.Class<? extends FileSystem> getConfigClass()
Description copied from class:FileSystemConfigBuilder
Get the target of this configuration.- Specified by:
getConfigClass
in classFileSystemConfigBuilder
- Returns:
- the specific file system class
-
getFileNameEncoding
public java.lang.String getFileNameEncoding(FileSystemOptions opts)
Gets the file name encoding.- Parameters:
opts
- The FileSystem options.- Returns:
- the file name encoding
-
getIdentities
@Deprecated public java.io.File[] getIdentities(FileSystemOptions opts)
Deprecated.As of 2.1 usegetIdentityInfo(FileSystemOptions)
Gets the identity files (your private key files).We use java.io.File because JSch cannot deal with VFS FileObjects.
- Parameters:
opts
- The FileSystem options.- Returns:
- the array of identity Files.
- See Also:
setIdentities(org.apache.commons.vfs2.FileSystemOptions, java.io.File...)
-
getIdentityInfo
public IdentityInfo[] getIdentityInfo(FileSystemOptions opts)
Gets the identity info.- Parameters:
opts
- The FileSystem options.- Returns:
- the array of identity info instances.
- See Also:
setIdentityInfo(org.apache.commons.vfs2.FileSystemOptions, org.apache.commons.vfs2.provider.sftp.IdentityInfo...)
-
getIdentityRepositoryFactory
public IdentityRepositoryFactory getIdentityRepositoryFactory(FileSystemOptions opts)
Get the identity repository factory.- Parameters:
opts
- The FileSystem options.- Returns:
- the IdentityRepositoryFactory
-
getKnownHosts
public java.io.File getKnownHosts(FileSystemOptions opts)
- Parameters:
opts
- The FileSystem options.- Returns:
- the known hosts File.
- See Also:
setKnownHosts(org.apache.commons.vfs2.FileSystemOptions, java.io.File)
-
getPreferredAuthentications
public java.lang.String getPreferredAuthentications(FileSystemOptions opts)
Gets authentication order.- Parameters:
opts
- The FileSystem options.- Returns:
- The authentication order.
- Since:
- 2.0
-
getProxyCommand
public java.lang.String getProxyCommand(FileSystemOptions opts)
Gets the command that will be run on the proxy host when using a SftpStreamProxy. The command defaults to SftpStreamProxy.NETCAT_COMMAND.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyOptions
- Since:
- 2.1
- See Also:
SftpStreamProxy
,setProxyOptions(org.apache.commons.vfs2.FileSystemOptions, org.apache.commons.vfs2.FileSystemOptions)
-
getProxyHost
public java.lang.String getProxyHost(FileSystemOptions opts)
Gets the proxy to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyHost
- See Also:
getProxyPort(org.apache.commons.vfs2.FileSystemOptions)
,setProxyHost(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)
-
getProxyOptions
public FileSystemOptions getProxyOptions(FileSystemOptions opts)
Gets the proxy options that are used to connect to the proxy host.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyOptions
- Since:
- 2.1
- See Also:
SftpStreamProxy
,setProxyOptions(org.apache.commons.vfs2.FileSystemOptions, org.apache.commons.vfs2.FileSystemOptions)
-
getProxyPassword
public java.lang.String getProxyPassword(FileSystemOptions opts)
Gets the proxy password that are used to connect to the proxy host.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyOptions
- Since:
- 2.1
- See Also:
SftpStreamProxy
,setProxyPassword(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)
-
getProxyPort
public int getProxyPort(FileSystemOptions opts)
Gets the proxy-port to use for the SFTP the connection.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyPort: the port number or 0 if it is not set
- See Also:
setProxyPort(org.apache.commons.vfs2.FileSystemOptions, int)
,getProxyHost(org.apache.commons.vfs2.FileSystemOptions)
-
getProxyType
public SftpFileSystemConfigBuilder.ProxyType getProxyType(FileSystemOptions opts)
Gets the proxy type to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.- Returns:
- The ProxyType.
-
getProxyUser
public java.lang.String getProxyUser(FileSystemOptions opts)
Gets the user name for the proxy used for the SFTP connection.- Parameters:
opts
- The FileSystem options.- Returns:
- proxyUser
- Since:
- 2.1
- See Also:
setProxyUser(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)
-
getStrictHostKeyChecking
public java.lang.String getStrictHostKeyChecking(FileSystemOptions opts)
- Parameters:
opts
- The FileSystem options.- Returns:
- the option value The host key checking.
- See Also:
setStrictHostKeyChecking(FileSystemOptions, String)
-
getTimeout
public java.lang.Integer getTimeout(FileSystemOptions opts)
- Parameters:
opts
- The FileSystem options.- Returns:
- The timeout value in milliseconds.
- See Also:
setTimeout(org.apache.commons.vfs2.FileSystemOptions, java.lang.Integer)
-
getUserDirIsRoot
public java.lang.Boolean getUserDirIsRoot(FileSystemOptions opts)
ReturnsBoolean.TRUE
if VFS should treat the user directory as the root directory. Defaults toBoolean.TRUE
if the methodsetUserDirIsRoot(FileSystemOptions, boolean)
has not been invoked.- Parameters:
opts
- The FileSystemOptions.- Returns:
Boolean.TRUE
if VFS treats the user directory as the root directory.- See Also:
setUserDirIsRoot(org.apache.commons.vfs2.FileSystemOptions, boolean)
-
getUserInfo
public com.jcraft.jsch.UserInfo getUserInfo(FileSystemOptions opts)
- Parameters:
opts
- The FileSystem options.- Returns:
- The UserInfo.
- See Also:
setUserInfo(org.apache.commons.vfs2.FileSystemOptions, com.jcraft.jsch.UserInfo)
-
setCompression
public void setCompression(FileSystemOptions opts, java.lang.String compression) throws FileSystemException
Configures the compression algorithms to use.For example, use
"zlib,none"
to enable compression.See the Jsch documentation (in particular the README file) for details.
- Parameters:
opts
- The FileSystem options.compression
- The names of the compression algorithms, comma-separated.- Throws:
FileSystemException
- if an error occurs.
-
setFileNameEncoding
public void setFileNameEncoding(FileSystemOptions opts, java.lang.String fileNameEncoding)
Sets the file name encoding.- Parameters:
opts
- The FileSystem options.fileNameEncoding
- The name of the encoding to use for file names.
-
setIdentities
@Deprecated public void setIdentities(FileSystemOptions opts, java.io.File... identityFiles) throws FileSystemException
Deprecated.As of 2.1 usesetIdentityInfo(FileSystemOptions, IdentityInfo...)
Sets the identity files (your private key files).We use
File
because JSch cannot deal with VFS FileObjects.- Parameters:
opts
- The FileSystem options.identityFiles
- An array of identity Files.- Throws:
FileSystemException
- if an error occurs.
-
setIdentityInfo
public void setIdentityInfo(FileSystemOptions opts, IdentityInfo... identites) throws FileSystemException
Sets the identity info (your private key files).- Parameters:
opts
- The FileSystem options.identites
- An array of identity info.- Throws:
FileSystemException
- if an error occurs.- Since:
- 2.1
-
setIdentityRepositoryFactory
public void setIdentityRepositoryFactory(FileSystemOptions opts, IdentityRepositoryFactory factory) throws FileSystemException
Set the identity repository.This is useful when you want to use e.g. an SSH agent as provided.
- Parameters:
opts
- The FileSystem options.factory
- An identity repository.- Throws:
FileSystemException
- if an error occurs.- See Also:
- JSch agent proxy
-
setKnownHosts
public void setKnownHosts(FileSystemOptions opts, java.io.File knownHosts) throws FileSystemException
Sets the known_hosts file. e.g./home/user/.ssh/known_hosts2
.We use
File
because JSch cannot deal with VFS FileObjects.- Parameters:
opts
- The FileSystem options.knownHosts
- The known hosts file.- Throws:
FileSystemException
- if an error occurs.
-
setPreferredAuthentications
public void setPreferredAuthentications(FileSystemOptions opts, java.lang.String preferredAuthentications)
Configures authentication order.- Parameters:
opts
- The FileSystem options.preferredAuthentications
- The authentication order.- Since:
- 2.0
-
setProxyCommand
public void setProxyCommand(FileSystemOptions opts, java.lang.String proxyCommand)
Sets the proxy username to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.proxyCommand
- the port- Since:
- 2.1
- See Also:
getProxyOptions(org.apache.commons.vfs2.FileSystemOptions)
-
setProxyHost
public void setProxyHost(FileSystemOptions opts, java.lang.String proxyHost)
Sets the proxy to use for the SFTP connection. You MUST also set the proxy port to use the proxy.- Parameters:
opts
- The FileSystem options.proxyHost
- the host- See Also:
setProxyPort(org.apache.commons.vfs2.FileSystemOptions, int)
-
setProxyOptions
public void setProxyOptions(FileSystemOptions opts, FileSystemOptions proxyOptions)
Sets the proxy username to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.proxyOptions
- the options- Since:
- 2.1
- See Also:
getProxyOptions(org.apache.commons.vfs2.FileSystemOptions)
-
setProxyPassword
public void setProxyPassword(FileSystemOptions opts, java.lang.String proxyPassword)
Sets the proxy password to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.proxyPassword
- the username used to connect to the proxy- Since:
- 2.1
- See Also:
getProxyPassword(org.apache.commons.vfs2.FileSystemOptions)
-
setProxyPort
public void setProxyPort(FileSystemOptions opts, int proxyPort)
Sets the proxy port to use for the SFTP connection.You MUST also set the proxy host to use the proxy.
- Parameters:
opts
- The FileSystem options.proxyPort
- the port- See Also:
setProxyHost(org.apache.commons.vfs2.FileSystemOptions, java.lang.String)
-
setProxyType
public void setProxyType(FileSystemOptions opts, SftpFileSystemConfigBuilder.ProxyType proxyType)
Sets the proxy type to use for the SFTP connection. The possibles values are:- PROXY_HTTP connects using an HTTP proxy
- PROXY_SOCKS5 connects using an Socket5 proxy
- PROXY_STREAM connects through a remote host stream command
- Parameters:
opts
- The FileSystem options.proxyType
- the type of the proxy to use.
-
setProxyUser
public void setProxyUser(FileSystemOptions opts, java.lang.String proxyUser)
Sets the proxy username to use for the SFTP connection.- Parameters:
opts
- The FileSystem options.proxyUser
- the username used to connect to the proxy- Since:
- 2.1
- See Also:
getProxyUser(org.apache.commons.vfs2.FileSystemOptions)
-
setStrictHostKeyChecking
public void setStrictHostKeyChecking(FileSystemOptions opts, java.lang.String hostKeyChecking) throws FileSystemException
Configures the host key checking to use.Valid arguments are:
"yes"
,"no"
and"ask"
.See the jsch documentation for details.
- Parameters:
opts
- The FileSystem options.hostKeyChecking
- The host key checking to use.- Throws:
FileSystemException
- if an error occurs.
-
setTimeout
public void setTimeout(FileSystemOptions opts, java.lang.Integer timeout)
Sets the timeout value on Jsch session.- Parameters:
opts
- The FileSystem options.timeout
- The timeout in milliseconds.
-
setUserDirIsRoot
public void setUserDirIsRoot(FileSystemOptions opts, boolean userDirIsRoot)
Sets the whether to use the user directory as root (do not change to file system root).- Parameters:
opts
- The FileSystem options.userDirIsRoot
- true if the user directory is the root directory.
-
setUserInfo
public void setUserInfo(FileSystemOptions opts, com.jcraft.jsch.UserInfo info)
Sets the Jsch UserInfo class to use.- Parameters:
opts
- The FileSystem options.info
- User information.
-
-