|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.schmizz.sshj.transport.TransportImpl
public final class TransportImpl
A thread-safe Transport implementation.
| Constructor Summary | |
|---|---|
TransportImpl(Config config)
|
|
| Method Summary | |
|---|---|
void |
addHostKeyVerifier(HostKeyVerifier hkv)
Adds the specified verifier. |
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,
String message)
Send a disconnect packet with the given reason and message, and closes this
transport. |
void |
doKex()
Do key exchange and algorithm negotiation. |
String |
getClientVersion()
|
Config |
getConfig()
|
DisconnectListener |
getDisconnectListener()
|
int |
getHeartbeatInterval()
|
String |
getRemoteHost()
|
int |
getRemotePort()
|
String |
getServerVersion()
Returns the version string as sent by the SSH server for identification purposes, e.g. |
Service |
getService()
|
byte[] |
getSessionID()
|
int |
getTimeout()
|
void |
handle(Message msg,
SSHPacket buf)
This is where all incoming packets are handled. |
void |
init(String remoteHost,
int remotePort,
InputStream in,
OutputStream out)
Sets the host information and the streams to be used by this transport. |
boolean |
isAuthenticated()
|
boolean |
isKexDone()
|
boolean |
isRunning()
|
void |
join()
Joins the thread calling this method to the transport's death. |
void |
join(int timeout,
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)
|
void |
setService(Service service)
Sets the currently active Service. |
void |
setTimeout(int timeout)
Set a timeout for methods that may block. |
long |
write(SSHPacket payload)
Write a packet over this transport. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TransportImpl(Config config)
| Method Detail |
|---|
public void init(String remoteHost,
int remotePort,
InputStream in,
OutputStream out)
throws TransportException
TransportTransportException is thrown in case of SSH protocol version incompatibility.
init in interface TransportremoteHost - server's hostnameremotePort - server's portin - input stream for the connectionout - output stream for the connection
TransportException - if there is an error during exchange of identification informationpublic void addHostKeyVerifier(HostKeyVerifier hkv)
Transport
addHostKeyVerifier in interface Transporthkv - the host key verifier
public void doKex()
throws TransportException
Transport
doKex in interface TransportTransportException - if there was an error during key exchangepublic boolean isKexDone()
public int getTimeout()
getTimeout in interface Transportpublic void setTimeout(int timeout)
Transport
setTimeout in interface Transporttimeout - the timeout in secondspublic int getHeartbeatInterval()
getHeartbeatInterval in interface Transportpublic void setHeartbeatInterval(int interval)
setHeartbeatInterval in interface Transportinterval - the interval in seconds, 0 means no hearbeatpublic String getRemoteHost()
getRemoteHost in interface Transportpublic int getRemotePort()
getRemotePort in interface Transportpublic String getClientVersion()
getClientVersion in interface Transportpublic Config getConfig()
getConfig in interface TransportConfig associated with this transport.public String getServerVersion()
TransportTransport.init(java.lang.String, int, java.io.InputStream, java.io.OutputStream), it will be null.
getServerVersion in interface Transportnull)public byte[] getSessionID()
getSessionID in interface Transportpublic Service getService()
getService in interface TransportService instance.public void setService(Service service)
TransportService. Handling of non-transport-layer packets is delegated to that service.
For this method to be successful, at least one service request via Transport.reqService(net.schmizz.sshj.Service) must have been successful
(not necessarily for the service being set).
setService in interface Transportservice - (null-ok) the Service
public void reqService(Service service)
throws TransportException
TransportService instance. A separate call to Transport.setService(net.schmizz.sshj.Service) is not
needed.
reqService in interface Transportservice - the SSH service to be requested
TransportException - if the request failed for any reasonpublic void setAuthenticated()
Transport
setAuthenticated in interface Transportpublic boolean isAuthenticated()
isAuthenticated in interface Transport
public long sendUnimplemented()
throws TransportException
Transport
sendUnimplemented in interface TransportTransportException - if an error occured sending the packet
public void join()
throws TransportException
Transport
join in interface TransportTransportException - if the transport dies of an exception
public void join(int timeout,
TimeUnit unit)
throws TransportException
Transport
join in interface TransportTransportException - if the transport dies of an exceptionpublic boolean isRunning()
isRunning in interface TransportTransport.init(java.lang.String, int, java.io.InputStream, java.io.OutputStream) and
has not been disconnected.public void disconnect()
TransportDisconnectReason.BY_APPLICATION, and closes this transport.
disconnect in interface Transportpublic void disconnect(DisconnectReason reason)
Transportreason, and closes this transport.
disconnect in interface Transportreason - reason for disconnecting
public void disconnect(DisconnectReason reason,
String message)
Transportreason and message, and closes this
transport.
disconnect in interface Transportreason - the reason code for this disconnectmessage - the text messagepublic void setDisconnectListener(DisconnectListener listener)
Transportlistener that will be notified upon disconnection.
setDisconnectListener in interface Transportpublic DisconnectListener getDisconnectListener()
getDisconnectListener in interface Transport
public long write(SSHPacket payload)
throws TransportException
Transportpayload 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).
write in interface Transportpayload - the SSHPacket containing data to send
TransportException - if an error occurred sending the packet
public void handle(Message msg,
SSHPacket buf)
throws SSHException
SSHPacketHandler.handle(net.schmizz.sshj.common.Message, net.schmizz.sshj.common.SSHPacket).
Even among the transport layer specific packets, key exchange packets are delegated to KeyExchanger.handle(net.schmizz.sshj.common.Message, net.schmizz.sshj.common.SSHPacket).
This method is called in the context of the reader thread via Decoder.received(byte[], int) when a full
packet has been decoded.
handle in interface SSHPacketHandlermsg - the message identiferbuf - buffer containg rest of the packet
SSHException - if an error occurs during handling (unrecoverable)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||