Class SftpStreamProxy
java.lang.Object
org.apache.commons.vfs2.provider.sftp.SftpStreamProxy
- All Implemented Interfaces:
com.jcraft.jsch.Proxy
Stream based proxy for JSch.
Use a command on the proxy that will forward the SSH stream to the target host and port.
- Since:
- 2.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCommand format using bash built-in TCP stream.private com.jcraft.jsch.ChannelExecprivate final StringCommand pattern to execute on the proxy host.static final StringCommand format using netcat command.private final StringHostname used to connect to the proxy host.private final FileSystemOptionsThe options for connection.private final StringThe password to be used for connection.private final intPort used to connect to the proxy host.private final StringUsername used to connect to the proxy host.private com.jcraft.jsch.Session -
Constructor Summary
ConstructorsConstructorDescriptionSftpStreamProxy(String commandFormat, String proxyUser, String proxyHost, int proxyPort, String proxyPassword, FileSystemOptions proxyOptions) Creates a stream proxy. -
Method Summary
-
Field Details
-
BASH_TCP_COMMAND
Command format using bash built-in TCP stream.- See Also:
-
NETCAT_COMMAND
-
channel
private com.jcraft.jsch.ChannelExec channel -
commandFormat
Command pattern to execute on the proxy host.When run, the command output should be forwarded to the target host and port, and its input should be forwarded from the target host and port.
The command will be created for each host/port pair by using String.format(String, Object...) with two objects: the target host name (String) and the target port (Integer).
Here are two examples (that can be easily used by using the static members of this class):
nc -q 0 %s %dto use the netcat command (NETCAT_COMMAND)/bin/bash -c 'exec 3<>/dev/tcp/%s/%d; cat <&3 & cat >&3; kill $!will use bash built-in TCP stream, which can be useful when there is no netcat available. (BASH_TCP_COMMAND)
-
proxyHost
Hostname used to connect to the proxy host. -
proxyOptions
The options for connection. -
proxyPassword
The password to be used for connection. -
proxyPort
private final int proxyPortPort used to connect to the proxy host. -
proxyUser
Username used to connect to the proxy host. -
session
private com.jcraft.jsch.Session session
-
-
Constructor Details
-
SftpStreamProxy
public SftpStreamProxy(String commandFormat, String proxyUser, String proxyHost, int proxyPort, String proxyPassword, FileSystemOptions proxyOptions) Creates a stream proxy.- Parameters:
commandFormat- A format string that will be used to create the command to execute on the proxy host using String.format(String, Object...). Two parameters are given to the format command, the target host name (String) and port (Integer).proxyUser- The proxy userproxyHost- The proxy hostproxyPort- The port to connect to on the proxyproxyPassword- The proxy passwordproxyOptions- Options used when connecting to the proxy
-
-
Method Details
-
close
public void close()- Specified by:
closein interfacecom.jcraft.jsch.Proxy
-
connect
-
getInputStream
- Specified by:
getInputStreamin interfacecom.jcraft.jsch.Proxy
-
getOutputStream
- Specified by:
getOutputStreamin interfacecom.jcraft.jsch.Proxy
-
getSocket
- Specified by:
getSocketin interfacecom.jcraft.jsch.Proxy
-