public interface Transport extends SSHPacketHandler
Modifier and Type | Method and Description |
---|---|
void |
addAlgorithmsVerifier(AlgorithmsVerifier verifier)
Adds the specified verifier.
|
void |
addHostKeyVerifier(HostKeyVerifier hkv)
Adds the specified verifier.
|
void |
die(java.lang.Exception e)
Kill the transport in an exceptional way.
|
void |
disconnect()
Send a disconnection packet with reason as
DisconnectReason.BY_APPLICATION , and closes this transport. |
void |
disconnect(DisconnectReason reason)
Send a disconnect packet with the given
reason , and closes this transport. |
void |
disconnect(DisconnectReason reason,
java.lang.String message)
Send a disconnect packet with the given
reason and message , and closes this
transport. |
void |
doKex()
Do key exchange and algorithm negotiation.
|
java.lang.String |
getClientVersion() |
Config |
getConfig() |
DisconnectListener |
getDisconnectListener() |
int |
getHeartbeatInterval()
Deprecated.
Moved to
KeepAlive.getKeepAliveInterval() . This is accessible through the Connection .
Scheduled to be removed in 0.12.0 |
java.lang.String |
getRemoteHost() |
int |
getRemotePort() |
java.lang.String |
getServerVersion()
Returns the version string as sent by the SSH server for identification purposes, e.g.
|
Service |
getService() |
byte[] |
getSessionID() |
int |
getTimeoutMs() |
void |
init(java.lang.String host,
int port,
java.io.InputStream in,
java.io.OutputStream out)
Sets the host information and the streams to be used by this transport.
|
boolean |
isAuthenticated() |
boolean |
isRunning() |
void |
join()
Joins the thread calling this method to the transport's death.
|
void |
join(int timeout,
java.util.concurrent.TimeUnit unit)
Joins the thread calling this method to the transport's death.
|
void |
reqService(Service service)
Request a SSH service represented by a
Service instance. |
long |
sendUnimplemented()
Sends SSH_MSG_UNIMPLEMENTED in response to the last packet received.
|
void |
setAuthenticated()
Informs this transport that authentication has been completed.
|
void |
setDisconnectListener(DisconnectListener listener)
Specify a
listener that will be notified upon disconnection. |
void |
setHeartbeatInterval(int interval)
Deprecated.
Moved to
KeepAlive.getKeepAliveInterval() . This is accessible through the Connection .
Scheduled to be removed in 0.12.0 |
void |
setService(Service service)
Sets the currently active
Service . |
void |
setTimeoutMs(int timeout)
Set a timeout for methods that may block.
|
long |
write(SSHPacket payload)
Write a packet over this transport.
|
handle
void init(java.lang.String host, int port, java.io.InputStream in, java.io.OutputStream out) throws TransportException
TransportException
is thrown in case of SSH protocol version incompatibility.host
- server's hostnameport
- server's portin
- input stream for the connectionout
- output stream for the connectionTransportException
- if there is an error during exchange of identification informationvoid addHostKeyVerifier(HostKeyVerifier hkv)
hkv
- the host key verifiervoid addAlgorithmsVerifier(AlgorithmsVerifier verifier)
verifier
- The verifier to call with negotiated algorithmsvoid doKex() throws TransportException
TransportException
- if there was an error during key exchangejava.lang.String getClientVersion()
int getTimeoutMs()
void setTimeoutMs(int timeout)
timeout
- the timeout in milliseconds@Deprecated int getHeartbeatInterval()
KeepAlive.getKeepAliveInterval()
. This is accessible through the Connection
.
Scheduled to be removed in 0.12.0@Deprecated void setHeartbeatInterval(int interval)
KeepAlive.getKeepAliveInterval()
. This is accessible through the Connection
.
Scheduled to be removed in 0.12.0interval
- the interval in seconds, 0
means no hearbeatjava.lang.String getRemoteHost()
int getRemotePort()
java.lang.String getServerVersion()
init(java.lang.String, int, java.io.InputStream, java.io.OutputStream)
, it will be null
.null
)byte[] getSessionID()
void reqService(Service service) throws TransportException
Service
instance. A separate call to setService(net.schmizz.sshj.Service)
is not
needed.service
- the SSH service to be requestedTransportException
- if the request failed for any reasonvoid setService(Service service)
Service
. Handling of non-transport-layer packets is delegated
to that service.
For this method to be successful, at least one service request via reqService(net.schmizz.sshj.Service)
must have been successful
(not necessarily for the service being set).service
- (null-ok) the Service
boolean isAuthenticated()
void setAuthenticated()
long sendUnimplemented() throws TransportException
TransportException
- if an error occured sending the packetboolean isRunning()
init(java.lang.String, int, java.io.InputStream, java.io.OutputStream)
and
has not been disconnected.void join() throws TransportException
TransportException
- if the transport dies of an exceptionvoid join(int timeout, java.util.concurrent.TimeUnit unit) throws TransportException
TransportException
- if the transport dies of an exceptionvoid disconnect()
DisconnectReason.BY_APPLICATION
, and closes this transport.void disconnect(DisconnectReason reason)
reason
, and closes this transport.reason
- reason for disconnectingvoid disconnect(DisconnectReason reason, java.lang.String message)
reason
and message
, and closes this
transport.reason
- the reason code for this disconnectmessage
- the text messagelong write(SSHPacket payload) throws TransportException
payload
SSHPacket
should have 5 bytes free at the beginning to avoid a performance penalty
associated with making space for header bytes (packet length, padding length).payload
- the SSHPacket
containing data to sendTransportException
- if an error occurred sending the packetvoid setDisconnectListener(DisconnectListener listener)
listener
that will be notified upon disconnection.listener
- DisconnectListener getDisconnectListener()
void die(java.lang.Exception e)
e
- The exception that occurred.