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 Modifier and Type Class Description static classTelnetConnection.Factory
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_PORTstatic intDEFAULT_TIMEOUTstatic StringHOSTNAME_ATTRstatic StringPASSWORD_ATTRstatic StringPORT_ATTRstatic StringTIMEOUT_ATTRstatic StringUSERNAME_ATTR
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the connection.voidconnectionChanged(RemoteConnectionChangeEvent event)Notifies this listener that the status of a connection has changed.IRemoteProcessgetCommandShell(int flags)Get a remote process that runs a command shell on the remote system.StringgetHostname()Obtain the hostname associated with this connection.StringgetPassphrase()Get the pass phrase associated with this connection.StringgetPassword()Get the password associated with this connection.intgetPort()Obtain the port associated with this connectionIRemoteConnectiongetRemoteConnection()intgetTimeout()Obtain the timeout used when establishing the connection.StringgetUsername()Obtain the username associated with this connection.booleanisOpen()Test if the connection is open.voidopen(org.eclipse.core.runtime.IProgressMonitor monitor)Open the connection.voidsetHostname(String hostname)Set the hostname associated with this connection.voidsetPassphrase(String passphrase)Set the pass phrase associated with this connection.voidsetPassword(String password)Set the password associated with this connection.voidsetPort(int port)Set the port used for the connection.voidsetTimeout(int timeout)Set the timeout used when establishing the connection.voidsetUseLoginShell(boolean useLogingShell)Set the flag indicating a login shell should be stated for this connection.voidsetUsePassword(boolean usePassword)Set the connection to try password authentication first.voidsetUsername(String username)Set the username associated with this connection.protected voidterminated(TelnetCommandShell shell)booleanuseLoginShell()Obtain the flag that indicates a login shell should be started once the connection is establishedbooleanusePassword()Get the value of the use password authentication flag.
-
-
-
Field Detail
-
DEFAULT_PORT
public static int DEFAULT_PORT
-
DEFAULT_TIMEOUT
public static int DEFAULT_TIMEOUT
-
HOSTNAME_ATTR
public static final String HOSTNAME_ATTR
- See Also:
- Constant Field Values
-
USERNAME_ATTR
public static final String USERNAME_ATTR
- See Also:
- Constant Field Values
-
PASSWORD_ATTR
public static final String PASSWORD_ATTR
- See Also:
- Constant Field Values
-
PORT_ATTR
public static final String PORT_ATTR
- See Also:
- Constant Field Values
-
TIMEOUT_ATTR
public static final String TIMEOUT_ATTR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getRemoteConnection
public IRemoteConnection getRemoteConnection()
- Specified by:
getRemoteConnectionin interfaceIRemoteConnection.Service
-
getCommandShell
public IRemoteProcess getCommandShell(int flags) throws IOException
Description copied from interface:IRemoteCommandShellServiceGet 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:
getCommandShellin interfaceIRemoteCommandShellService- Parameters:
flags- bitwise-or of flags- Returns:
- remote process object
- Throws:
IOException
-
getPort
public int getPort()
Description copied from interface:IRemoteConnectionHostServiceObtain the port associated with this connection- Specified by:
getPortin interfaceIRemoteConnectionHostService- Returns:
- port
-
getTimeout
public int getTimeout()
Description copied from interface:IRemoteConnectionHostServiceObtain the timeout used when establishing the connection.- Specified by:
getTimeoutin interfaceIRemoteConnectionHostService- Returns:
- timeout
-
close
public void close()
Description copied from interface:IRemoteConnectionControlServiceClose the connection. Must be called to terminate the connection.- Specified by:
closein interfaceIRemoteConnectionControlService
-
getHostname
public String getHostname()
Description copied from interface:IRemoteConnectionHostServiceObtain the hostname associated with this connection.- Specified by:
getHostnamein interfaceIRemoteConnectionHostService- Returns:
- hostname
-
useLoginShell
public boolean useLoginShell()
Description copied from interface:IRemoteConnectionHostServiceObtain the flag that indicates a login shell should be started once the connection is established- Specified by:
useLoginShellin interfaceIRemoteConnectionHostService- Returns:
- login shell flag
-
getUsername
public String getUsername()
Description copied from interface:IRemoteConnectionHostServiceObtain the username associated with this connection.- Specified by:
getUsernamein interfaceIRemoteConnectionHostService- Returns:
-
setHostname
public void setHostname(String hostname)
Description copied from interface:IRemoteConnectionHostServiceSet the hostname associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setHostnamein interfaceIRemoteConnectionHostService- Parameters:
hostname- new hostname for connection
-
setPassphrase
public void setPassphrase(String passphrase)
Description copied from interface:IRemoteConnectionHostServiceSet 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:
setPassphrasein interfaceIRemoteConnectionHostService
-
setPassword
public void setPassword(String password)
Description copied from interface:IRemoteConnectionHostServiceSet the password associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setPasswordin interfaceIRemoteConnectionHostService- Parameters:
password- new password for connection
-
setPort
public void setPort(int port)
Description copied from interface:IRemoteConnectionHostServiceSet the port used for the connection. Note, this method can only be used forh an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setPortin interfaceIRemoteConnectionHostService- Parameters:
port- new port for connection
-
setTimeout
public void setTimeout(int timeout)
Description copied from interface:IRemoteConnectionHostServiceSet 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:
setTimeoutin interfaceIRemoteConnectionHostService- Parameters:
timeout- new timeout value
-
setUseLoginShell
public void setUseLoginShell(boolean useLogingShell)
Description copied from interface:IRemoteConnectionHostServiceSet 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:
setUseLoginShellin interfaceIRemoteConnectionHostService- Parameters:
useLogingShell- true to start a login shell
-
setUsePassword
public void setUsePassword(boolean usePassword)
Description copied from interface:IRemoteConnectionHostServiceSet 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:
setUsePasswordin interfaceIRemoteConnectionHostService- Parameters:
usePassword- use password authentication
-
setUsername
public void setUsername(String username)
Description copied from interface:IRemoteConnectionHostServiceSet the username associated with this connection. Note, this method can only be used for an IRemoteConnectionWorkingCopy and will have no effect otherwise.- Specified by:
setUsernamein interfaceIRemoteConnectionHostService- Parameters:
username- new username for connection
-
open
public void open(org.eclipse.core.runtime.IProgressMonitor monitor) throws RemoteConnectionExceptionDescription copied from interface:IRemoteConnectionControlServiceOpen the connection. Must be called before the connection can be used.- Specified by:
openin 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:IRemoteConnectionControlServiceTest if the connection is open.- Specified by:
isOpenin interfaceIRemoteConnectionControlService- Returns:
- true if connection is open.
-
connectionChanged
public void connectionChanged(RemoteConnectionChangeEvent event)
Description copied from interface:IRemoteConnectionChangeListenerNotifies this listener that the status of a connection has changed.- Specified by:
connectionChangedin interfaceIRemoteConnectionChangeListener- Parameters:
event- the connection change event
-
terminated
protected void terminated(TelnetCommandShell shell)
-
getPassphrase
public String getPassphrase()
Description copied from interface:IRemoteConnectionHostServiceGet the pass phrase associated with this connection.- Specified by:
getPassphrasein interfaceIRemoteConnectionHostService- Returns:
- pass phrase
-
getPassword
public String getPassword()
Description copied from interface:IRemoteConnectionHostServiceGet the password associated with this connection.- Specified by:
getPasswordin interfaceIRemoteConnectionHostService- Returns:
- password
-
usePassword
public boolean usePassword()
Description copied from interface:IRemoteConnectionHostServiceGet the value of the use password authentication flag. If true, the connection will try using a password first.- Specified by:
usePasswordin interfaceIRemoteConnectionHostService- Returns:
- use password authentication flag
-
-