public class JSchConnection extends java.lang.Object implements IRemoteConnectionControlService, IRemoteConnectionPropertyService, IRemotePortForwardingService, IRemoteProcessService, IRemoteConnectionHostService, IRemoteConnectionChangeListener
| Modifier and Type | Class and Description |
|---|---|
static class |
JSchConnection.Factory |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ADDRESS_ATTR |
static boolean |
DEFAULT_IS_PASSWORD |
static java.lang.String |
DEFAULT_LOGIN_SHELL_COMMAND |
static int |
DEFAULT_PORT |
static int |
DEFAULT_TIMEOUT |
static boolean |
DEFAULT_USE_LOGIN_SHELL |
static java.lang.String |
EMPTY_STRING |
static java.lang.String |
IS_PASSWORD_ATTR |
static java.lang.String |
JSCH_ID |
static java.lang.String |
LOGIN_SHELL_COMMAND_ATTR |
static java.lang.String |
PASSPHRASE_ATTR |
static java.lang.String |
PASSWORD_ATTR |
static java.lang.String |
PORT_ATTR |
static java.lang.String |
PROXYCOMMAND_ATTR |
static java.lang.String |
PROXYCONNECTION_ATTR |
static java.lang.String |
TIMEOUT_ATTR |
static java.lang.String |
USE_LOGIN_SHELL_ATTR |
static java.lang.String |
USERNAME_ATTR |
| Constructor and Description |
|---|
JSchConnection(IRemoteConnection connection) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection.
|
void |
connectionChanged(RemoteConnectionChangeEvent event)
Notifies this listener that the status of a connection has changed.
|
void |
forwardLocalPort(int localPort,
java.lang.String fwdAddress,
int fwdPort)
Forward local port localPort to remote port fwdPort on remote machine fwdAddress.
|
int |
forwardLocalPort(java.lang.String fwdAddress,
int fwdPort,
org.eclipse.core.runtime.IProgressMonitor monitor)
Forward a local port to remote port fwdPort on remote machine fwdAddress.
|
void |
forwardRemotePort(int remotePort,
java.lang.String fwdAddress,
int fwdPort)
Forward remote port remotePort to port fwdPort on machine fwdAddress.
|
int |
forwardRemotePort(java.lang.String fwdAddress,
int fwdPort,
org.eclipse.core.runtime.IProgressMonitor monitor)
Forward a remote port to port fwdPort on remote machine fwdAddress.
|
java.util.Map<java.lang.String,java.lang.String> |
getEnv()
Returns an unmodifiable string map view of the remote environment.
|
java.lang.String |
getEnv(java.lang.String name)
Returns the value of an environment variable.
|
com.jcraft.jsch.ChannelExec |
getExecChannel()
Open an exec channel to the remote host.
|
java.lang.String |
getHostname()
Obtain the hostname associated with this connection.
|
java.lang.String |
getLoginShellCommand()
Get the login shell command if useLoginShell is true
|
java.lang.String |
getPassphrase() |
java.lang.String |
getPassword() |
int |
getPort()
Obtain the port associated with this connection
|
IRemoteProcessBuilder |
getProcessBuilder(java.util.List<java.lang.String> command)
Get a process builder for creating remote processes
|
IRemoteProcessBuilder |
getProcessBuilder(java.lang.String... command)
Get a process builder for creating remote processes
|
java.lang.String |
getProperty(java.lang.String key)
Gets the remote system property indicated by the specified key.
|
java.lang.String |
getProxyCommand()
Gets the proxy command.
|
JSchConnection |
getProxyConnection()
Gets the proxy connection.
|
java.lang.String |
getProxyConnectionName()
Gets the proxy connection name
|
IRemoteConnection |
getRemoteConnection() |
com.jcraft.jsch.ChannelSftp |
getSftpCommandChannel()
Open an sftp command channel to the remote host.
|
com.jcraft.jsch.ChannelShell |
getShellChannel()
Open a shell channel to the remote host.
|
com.jcraft.jsch.Channel |
getStreamForwarder(java.lang.String host,
int port) |
int |
getTimeout()
Obtain the timeout used when establishing the connection.
|
java.lang.String |
getUsername()
Obtain the username associated with this connection.
|
java.lang.String |
getWorkingDirectory()
Get the working directory.
|
boolean |
hasOpenSession()
Test if the connection has a valid open session.
|
boolean |
isOpen()
Test if the connection is open.
|
boolean |
isPasswordAuth() |
com.jcraft.jsch.ChannelSftp |
newSftpChannel()
Open a channel for long running commands.
|
void |
open(org.eclipse.core.runtime.IProgressMonitor monitor)
Open the connection.
|
void |
openMinimal(org.eclipse.core.runtime.IProgressMonitor monitor)
Open ssh connection without full setup (environment, sftp)
|
void |
removeLocalPortForwarding(int port)
Remove the local port forwarding associated with the given port.
|
void |
removeRemotePortForwarding(int port)
Remove the remote port forwarding associated with the given port.
|
void |
setHostname(java.lang.String hostname)
Set the hostname associated with this connection.
|
void |
setPassphrase(java.lang.String passphrase)
Set the pass phrase associated with this connection.
|
void |
setPassword(java.lang.String password)
Set the password associated with this connection.
|
void |
setPort(int port)
Set the port used for the connection.
|
void |
setTimeout(int timeout)
Set the timeout used when establishing the connection.
|
void |
setUseLoginShell(boolean useLogingShell)
Set the flag indicating a login shell should be stated for this connection.
|
void |
setUsePassword(boolean usePassword)
Set the connection to try password authentication first.
|
void |
setUsername(java.lang.String username)
Set the username associated with this connection.
|
void |
setWorkingDirectory(java.lang.String path)
Set the working directory while the connection is open.
|
boolean |
useLoginShell()
Obtain the flag that indicates a login shell should be started once the connection is established
|
public static final java.lang.String JSCH_ID
public static final java.lang.String ADDRESS_ATTR
public static final java.lang.String USERNAME_ATTR
public static final java.lang.String PASSWORD_ATTR
public static final java.lang.String PORT_ATTR
public static final java.lang.String PROXYCONNECTION_ATTR
public static final java.lang.String PROXYCOMMAND_ATTR
public static final java.lang.String IS_PASSWORD_ATTR
public static final java.lang.String PASSPHRASE_ATTR
public static final java.lang.String TIMEOUT_ATTR
public static final java.lang.String USE_LOGIN_SHELL_ATTR
public static final java.lang.String LOGIN_SHELL_COMMAND_ATTR
public static final int DEFAULT_PORT
public static final int DEFAULT_TIMEOUT
public static final boolean DEFAULT_IS_PASSWORD
public static final boolean DEFAULT_USE_LOGIN_SHELL
public static final java.lang.String DEFAULT_LOGIN_SHELL_COMMAND
public static final java.lang.String EMPTY_STRING
public JSchConnection(IRemoteConnection connection)
public void connectionChanged(RemoteConnectionChangeEvent event)
IRemoteConnectionChangeListenerconnectionChanged in interface IRemoteConnectionChangeListenerevent - the connection change eventpublic IRemoteConnection getRemoteConnection()
getRemoteConnection in interface IRemoteConnection.Servicepublic void close()
IRemoteConnectionControlServiceclose in interface IRemoteConnectionControlServicepublic void forwardLocalPort(int localPort,
java.lang.String fwdAddress,
int fwdPort)
throws RemoteConnectionException
IRemotePortForwardingServiceforwardLocalPort in interface IRemotePortForwardingServicelocalPort - local port to forwardfwdAddress - address of remote machinefwdPort - remote port on remote machineRemoteConnectionExceptionpublic int forwardLocalPort(java.lang.String fwdAddress,
int fwdPort,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws RemoteConnectionException
IRemotePortForwardingServiceforwardLocalPort in interface IRemotePortForwardingServiceRemoteConnectionExceptionpublic void forwardRemotePort(int remotePort,
java.lang.String fwdAddress,
int fwdPort)
throws RemoteConnectionException
IRemotePortForwardingServiceforwardRemotePort in interface IRemotePortForwardingServiceremotePort - remote port to forwardfwdAddress - address of recipient machinefwdPort - port on recipient machineRemoteConnectionExceptionpublic int forwardRemotePort(java.lang.String fwdAddress,
int fwdPort,
org.eclipse.core.runtime.IProgressMonitor monitor)
throws RemoteConnectionException
IRemotePortForwardingServiceforwardRemotePort in interface IRemotePortForwardingServiceRemoteConnectionExceptionpublic java.lang.String getHostname()
IRemoteConnectionHostServicegetHostname in interface IRemoteConnectionHostServicepublic java.util.Map<java.lang.String,java.lang.String> getEnv()
IRemoteProcessServicegetEnv in interface IRemoteProcessServicepublic java.lang.String getEnv(java.lang.String name)
IRemoteProcessServicegetEnv in interface IRemoteProcessServicename - name of the environment variablepublic com.jcraft.jsch.ChannelExec getExecChannel()
throws RemoteConnectionException
RemoteConnectionException - if a channel could not be openedpublic com.jcraft.jsch.ChannelShell getShellChannel()
throws RemoteConnectionException
RemoteConnectionException - if a channel could not be openedpublic java.lang.String getPassphrase()
public java.lang.String getPassword()
public int getPort()
IRemoteConnectionHostServicegetPort in interface IRemoteConnectionHostServicepublic IRemoteProcessBuilder getProcessBuilder(java.util.List<java.lang.String> command)
IRemoteProcessServicegetProcessBuilder in interface IRemoteProcessServicepublic IRemoteProcessBuilder getProcessBuilder(java.lang.String... command)
IRemoteProcessServicegetProcessBuilder in interface IRemoteProcessServicepublic java.lang.String getProperty(java.lang.String key)
IRemoteConnectionPropertyServicegetProperty in interface IRemoteConnectionPropertyServicekey - the name of the propertypublic java.lang.String getLoginShellCommand()
public java.lang.String getProxyCommand()
public JSchConnection getProxyConnection()
public java.lang.String getProxyConnectionName()
public com.jcraft.jsch.ChannelSftp getSftpCommandChannel()
throws RemoteConnectionException
RemoteConnectionException - if a channel could not be openedpublic com.jcraft.jsch.ChannelSftp newSftpChannel()
throws RemoteConnectionException
RemoteConnectionException - if a channel could not be openedpublic com.jcraft.jsch.Channel getStreamForwarder(java.lang.String host,
int port)
throws RemoteConnectionException
RemoteConnectionExceptionpublic int getTimeout()
IRemoteConnectionHostServicegetTimeout in interface IRemoteConnectionHostServicepublic java.lang.String getUsername()
IRemoteConnectionHostServicegetUsername in interface IRemoteConnectionHostServicepublic java.lang.String getWorkingDirectory()
IRemoteProcessServicegetWorkingDirectory in interface IRemoteProcessServicepublic boolean hasOpenSession()
public boolean isOpen()
IRemoteConnectionControlServiceisOpen in interface IRemoteConnectionControlServicepublic boolean isPasswordAuth()
public void open(org.eclipse.core.runtime.IProgressMonitor monitor)
throws RemoteConnectionException
IRemoteConnectionControlServiceopen in interface IRemoteConnectionControlServicemonitor - the progress monitor to use for reporting progress to the user. It is the caller's responsibility to call done()
on the given monitor. Accepts null, indicating that no progress should be reported and that the operation cannot
be cancelled.RemoteConnectionExceptionpublic void openMinimal(org.eclipse.core.runtime.IProgressMonitor monitor)
throws RemoteConnectionException
monitor - RemoteConnectionExceptionorg.eclipse.remote.core.IRemoteConnection#open()public void removeLocalPortForwarding(int port)
throws RemoteConnectionException
IRemotePortForwardingServiceremoveLocalPortForwarding in interface IRemotePortForwardingServiceport - forwarded portRemoteConnectionExceptionpublic void removeRemotePortForwarding(int port)
throws RemoteConnectionException
IRemotePortForwardingServiceremoveRemotePortForwarding in interface IRemotePortForwardingServiceport - forwarded portRemoteConnectionExceptionpublic void setWorkingDirectory(java.lang.String path)
IRemoteProcessServicesetWorkingDirectory in interface IRemoteProcessServicepath - String representing the current working directorypublic boolean useLoginShell()
IRemoteConnectionHostServiceuseLoginShell in interface IRemoteConnectionHostServicepublic void setHostname(java.lang.String hostname)
IRemoteConnectionHostServicesetHostname in interface IRemoteConnectionHostServicehostname - new hostname for connectionpublic void setPassphrase(java.lang.String passphrase)
IRemoteConnectionHostServicesetPassphrase in interface IRemoteConnectionHostServicepublic void setPassword(java.lang.String password)
IRemoteConnectionHostServicesetPassword in interface IRemoteConnectionHostServicepassword - new password for connectionpublic void setPort(int port)
IRemoteConnectionHostServicesetPort in interface IRemoteConnectionHostServiceport - new port for connectionpublic void setTimeout(int timeout)
IRemoteConnectionHostServicesetTimeout in interface IRemoteConnectionHostServicetimeout - new timeout valuepublic void setUseLoginShell(boolean useLogingShell)
IRemoteConnectionHostServicesetUseLoginShell in interface IRemoteConnectionHostServiceuseLogingShell - true to start a login shellpublic void setUsePassword(boolean usePassword)
IRemoteConnectionHostServicesetUsePassword in interface IRemoteConnectionHostServiceusePassword - use password authenticationpublic void setUsername(java.lang.String username)
IRemoteConnectionHostServicesetUsername in interface IRemoteConnectionHostServiceusername - new username for connection