Package org.eclipse.remote.telnet.core
Class TelnetConnection
java.lang.Object
org.eclipse.remote.telnet.core.TelnetConnection
- All Implemented Interfaces:
EventListener
,IRemoteCommandShellService
,IRemoteConnection.Service
,IRemoteConnectionChangeListener
,IRemoteConnectionControlService
,IRemoteConnectionHostService
public class TelnetConnection
extends Object
implements IRemoteConnectionControlService, IRemoteCommandShellService, IRemoteConnectionHostService, IRemoteConnectionChangeListener
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the connection.void
Notifies this listener that the status of a connection has changed.getCommandShell
(int flags) Get a remote process that runs a command shell on the remote system.Obtain the hostname associated with this connection.Get the pass phrase associated with this connection.Get the password associated with this connection.int
getPort()
Obtain the port associated with this connectionint
Obtain the timeout used when establishing the connection.Obtain the username associated with this connection.boolean
isOpen()
Test if the connection is open.void
open
(org.eclipse.core.runtime.IProgressMonitor monitor) Open the connection.void
setHostname
(String hostname) Set the hostname associated with this connection.void
setPassphrase
(String passphrase) Set the pass phrase associated with this connection.void
setPassword
(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
(String username) Set the username associated with this connection.protected void
terminated
(TelnetCommandShell shell) boolean
Obtain the flag that indicates a login shell should be started once the connection is establishedboolean
Get the value of the use password authentication flag.
-
Field Details
-
DEFAULT_PORT
public static int DEFAULT_PORT -
DEFAULT_TIMEOUT
public static int DEFAULT_TIMEOUT -
HOSTNAME_ATTR
- See Also:
-
USERNAME_ATTR
- See Also:
-
PASSWORD_ATTR
- See Also:
-
PORT_ATTR
- See Also:
-
TIMEOUT_ATTR
- See Also:
-
-
Method Details
-
getRemoteConnection
- Specified by:
getRemoteConnection
in interfaceIRemoteConnection.Service
-
getCommandShell
Description copied from interface:IRemoteCommandShellService
Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types of remote service providers. Clients can useIRemoteProcessBuilder.getSupportedFlags()
to find out the flags supported by the service provider.Current flags are:
IRemoteProcessBuilder.NONE
- disable any flagsIRemoteProcessBuilder.ALLOCATE_PTY
- allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)IRemoteProcessBuilder.FORWARD_X11
- enable X11 forwarding (RFC-4254 Sec. 6.3)- Specified by:
getCommandShell
in interfaceIRemoteCommandShellService
- Parameters:
flags
- bitwise-or of flags- Returns:
- remote process object
- Throws:
IOException
-
getPort
public int getPort()Description copied from interface:IRemoteConnectionHostService
Obtain the port associated with this connection- Specified by:
getPort
in interfaceIRemoteConnectionHostService
- Returns:
- port
-
getTimeout
public int getTimeout()Description copied from interface:IRemoteConnectionHostService
Obtain the timeout used when establishing the connection.- Specified by:
getTimeout
in interfaceIRemoteConnectionHostService
- Returns:
- timeout
-
close
public void close()Description copied from interface:IRemoteConnectionControlService
Close the connection. Must be called to terminate the connection.- Specified by:
close
in interfaceIRemoteConnectionControlService
-
getHostname
Description copied from interface:IRemoteConnectionHostService
Obtain the hostname associated with this connection.- Specified by:
getHostname
in interfaceIRemoteConnectionHostService
- Returns:
- hostname
-
useLoginShell
public boolean useLoginShell()Description copied from interface:IRemoteConnectionHostService
Obtain the flag that indicates a login shell should be started once the connection is established- Specified by:
useLoginShell
in interfaceIRemoteConnectionHostService
- Returns:
- login shell flag
-
getUsername
Description copied from interface:IRemoteConnectionHostService
Obtain the username associated with this connection.- Specified by:
getUsername
in interfaceIRemoteConnectionHostService
- Returns:
-
setHostname
Description copied from interface:IRemoteConnectionHostService
Set the hostname associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setHostname
in interfaceIRemoteConnectionHostService
- Parameters:
hostname
- new hostname for connection
-
setPassphrase
Description copied from interface:IRemoteConnectionHostService
Set the pass phrase associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setPassphrase
in interfaceIRemoteConnectionHostService
- Parameters:
passphrase
-
-
setPassword
Description copied from interface:IRemoteConnectionHostService
Set the password associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setPassword
in interfaceIRemoteConnectionHostService
- Parameters:
password
- new password for connection
-
setPort
public void setPort(int port) Description copied from interface:IRemoteConnectionHostService
Set the port used for the connection. Note, this method can only be used forh an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setPort
in interfaceIRemoteConnectionHostService
- Parameters:
port
- new port for connection
-
setTimeout
public void setTimeout(int timeout) Description copied from interface:IRemoteConnectionHostService
Set the timeout used when establishing the connection. A timeout of 0 means infinite. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setTimeout
in interfaceIRemoteConnectionHostService
- Parameters:
timeout
- new timeout value
-
setUseLoginShell
public void setUseLoginShell(boolean useLogingShell) Description copied from interface:IRemoteConnectionHostService
Set the flag indicating a login shell should be stated for this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setUseLoginShell
in interfaceIRemoteConnectionHostService
- Parameters:
useLogingShell
- true to start a login shell
-
setUsePassword
public void setUsePassword(boolean usePassword) Description copied from interface:IRemoteConnectionHostService
Set the connection to try password authentication first. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setUsePassword
in interfaceIRemoteConnectionHostService
- Parameters:
usePassword
- use password authentication
-
setUsername
Description copied from interface:IRemoteConnectionHostService
Set the username associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setUsername
in interfaceIRemoteConnectionHostService
- Parameters:
username
- new username for connection
-
open
public void open(org.eclipse.core.runtime.IProgressMonitor monitor) throws RemoteConnectionException Description copied from interface:IRemoteConnectionControlService
Open the connection. Must be called before the connection can be used.- Specified by:
open
in interfaceIRemoteConnectionControlService
- Parameters:
monitor
- 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.- Throws:
RemoteConnectionException
-
isOpen
public boolean isOpen()Description copied from interface:IRemoteConnectionControlService
Test if the connection is open.- Specified by:
isOpen
in interfaceIRemoteConnectionControlService
- Returns:
- true if connection is open.
-
connectionChanged
Description copied from interface:IRemoteConnectionChangeListener
Notifies this listener that the status of a connection has changed.- Specified by:
connectionChanged
in interfaceIRemoteConnectionChangeListener
- Parameters:
event
- the connection change event
-
terminated
-
getPassphrase
Description copied from interface:IRemoteConnectionHostService
Get the pass phrase associated with this connection.- Specified by:
getPassphrase
in interfaceIRemoteConnectionHostService
- Returns:
- pass phrase
-
getPassword
Description copied from interface:IRemoteConnectionHostService
Get the password associated with this connection.- Specified by:
getPassword
in interfaceIRemoteConnectionHostService
- Returns:
- password
-
usePassword
public boolean usePassword()Description copied from interface:IRemoteConnectionHostService
Get the value of the use password authentication flag. If true, the connection will try using a password first.- Specified by:
usePassword
in interfaceIRemoteConnectionHostService
- Returns:
- use password authentication flag
-