|
AdventNet CLI 2.0 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.adventnet.cli.transport.ssh.sshv2.SshToolsProviderImpl
This class can be used to establish secure telnet connection with a device using SSH2 protocol. It makes use of SshTools for communicating with the remote host using SSH2 protocol. It implements the CLITransportProvider which has methods such as open, read, write.
| Fields inherited from interface com.adventnet.cli.transport.CLITransportProvider |
STREAM_CLOSED |
| Constructor Summary | |
SshToolsProviderImpl()
Constructor for the SshToolsProviderImpl object. |
|
| Method Summary | |
void |
close()
This closes the SSH connection to the remote device. |
void |
connect(com.sshtools.j2ssh.configuration.SshConnectionProperties properties,
com.sshtools.j2ssh.transport.HostKeyVerification hostVerification)
Connects to client to a SSH server |
void |
connect(java.lang.String hostname)
Opens connection to a SSH server on the standard port 22 using the default SshHostKeyVerification instance to verify
the host key. |
void |
connect(java.lang.String hostname,
int port)
Connects the client to a SSH server on any given port using the default SshHostKeyVerification
instance to verify the host key. |
void |
connect(java.lang.String hostname,
int port,
com.sshtools.j2ssh.transport.HostKeyVerification hosts)
Connects the client to a SSH server using the HostKeyVerification as given by the user.All connection properties such as cipher and message authentication algorithms are defaulted. |
void |
disconnect()
Disconnects the SSH connection |
int |
getRemoteEOL()
When the transport protocol negotiates the protocol version, it uses the EOL provided with the protocol identification string as the guessed EOL setting for the remote computer. The value returned will be any of the following values: TransportProtocol.EOL_CRLF TransportProtocol.EOL_LF |
java.lang.String |
getTerminalType()
Gets the current terminal type. |
boolean |
isConnected()
Determine if the client is connected. |
void |
login(java.lang.String username,
java.lang.String password)
Logs into the remote host. |
java.lang.String |
login(java.lang.String username,
java.lang.String password,
java.lang.String prompt)
This will log into the device with a particular login name and password. |
void |
onChannelData(com.sshtools.j2ssh.connection.SshMsgChannelData msg)
The response is asynchronously obtained here, which is intimated to the session. |
void |
onChannelExtData(com.sshtools.j2ssh.connection.SshMsgChannelExtendedData msg)
The response for extended data is obtained here. |
void |
open(CLIProtocolOptions cliProtOpt)
Opens a SSH connection to the remote device. |
CLIMessage |
read()
Receives the CLI message from the opened telnet connection. |
int |
read(byte[] b)
Read decrypted data from the backend. |
void |
setMessageTimeout(int timeout)
Sets the timeout for the login or any command sent. |
void |
setSocketTimeout(int timeout)
Sets the socket timeout. |
void |
setTerminalType(java.lang.String term)
Sets the terminal type of the remote machine. |
java.lang.String |
waitfor(java.lang.String match)
Waits for a string to be returned by the remote host and returns all those characters which are received until the match is obtained (including the string being waited for). |
void |
write(byte[] b)
Sends the data to the device after encrypting it. |
void |
write(CLIMessage cliMsg)
Sends the command in the CLIMessage. |
| Constructor Detail |
public SshToolsProviderImpl()
throws SshException
| Method Detail |
public boolean isConnected()
public int getRemoteEOL()
public void connect(java.lang.String hostname)
throws ConnectException
SshHostKeyVerification instance to verify
the host key.
When the connection is established with the SSH server for the first
time, the host key will be unknown to the Ssh client. Hence, it prompts
for the user's input with the following message -
"Do you want to allow this host key?[yes/no/always].
Choosing the "always" option, makes an entry for the remote host in the conf/hosts.xml
under the
hostname - the hostname to connect
public void connect(java.lang.String hostname,
int port)
throws ConnectException
SshHostKeyVerification
instance to verify the host key.
When the connection is established with the SSH server for the first
time, the host key will be unknown to the Ssh client. Hence, it prompts
for the user's input with the following message -
"Do you want to allow this host key?[yes/no/always].
Choosing the "always" option, makes an entry for the remote host in the conf/hosts.xml
under the
hostname - the hostname to connectport - the port to connect
public void connect(java.lang.String hostname,
int port,
com.sshtools.j2ssh.transport.HostKeyVerification hosts)
throws ConnectException
HostKeyVerification as given by the user.hostname - the hostname to connectport - the port to connecthosts - a host key verification implementation for user interaction
to verifiy the servers host key.
public void connect(com.sshtools.j2ssh.configuration.SshConnectionProperties properties,
com.sshtools.j2ssh.transport.HostKeyVerification hostVerification)
throws ConnectException
properties - the connection properties to usehostVerification - a host key verification implementation for user
interaction to verifiy the servers host key.public void disconnect()
public void setTerminalType(java.lang.String term)
terminalType - the terminal that the remote machine emulates
such as vt100, vt320 or others as a String value.public java.lang.String getTerminalType()
String value.public void setMessageTimeout(int timeout)
public void setSocketTimeout(int timeout)
throws java.io.IOException
timeout - an int value
public void login(java.lang.String username,
java.lang.String password)
throws LoginException
user - the login name as a string value.pwd - the password as a string value.
public java.lang.String login(java.lang.String username,
java.lang.String password,
java.lang.String prompt)
throws LoginException
username - the login namepassword - the passwordprompt - the shell promptString value
public void onChannelData(com.sshtools.j2ssh.connection.SshMsgChannelData msg)
throws com.sshtools.j2ssh.transport.TransportProtocolException,
com.sshtools.j2ssh.transport.ServiceOperationException
msg - a SshMsgChannelData value
public void onChannelExtData(com.sshtools.j2ssh.connection.SshMsgChannelExtendedData msg)
throws com.sshtools.j2ssh.transport.TransportProtocolException,
com.sshtools.j2ssh.transport.ServiceOperationException
msg - a SshMsgChannelExtendedData value
public int read(byte[] b)
throws java.io.IOException
b - the buffer to read the decrypted data in
public void write(byte[] b)
throws java.io.IOException
data - the data/command to be sent as a String value.
public java.lang.String waitfor(java.lang.String match)
throws java.io.IOException
match - the string to be received from the remote host which
determines the end of response.
public void open(CLIProtocolOptions cliProtOpt)
throws java.lang.Exception,
ConnectException,
LoginException
cliProtOpt - the CLIProtocolOptions with the parameters.public void close()
public void write(CLIMessage cliMsg)
throws java.io.IOException
cliMsg - the CLIMessage that has to be sent. The CLI
command (as a string) is obtained by calling
cliMsg.getData().
public CLIMessage read()
throws java.io.IOException
|
AdventNet CLI 2.0 API Specification | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||