|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sshtools.j2ssh.transport.Service | +--com.sshtools.j2ssh.connection.ConnectionProtocol
Implementation for the SSH connection protocol as a transport layer service. This class provides method for sending all the available connection protocol message as well as abstract methods for handling the same messages.
Constructor Summary | |
ConnectionProtocol()
Constructor for the SshConnectionProtocol object |
Method Summary | |
protected void |
closeChannel(Channel channel)
Closes the channel by sending the SSH_MSG_CHANNEL_CLOSE message. |
protected abstract void |
onChannelClose(Channel channel)
Implement this method to handle the SSH_MSG_CHANNEL_CLOSE message. |
protected abstract void |
onChannelData(Channel channel,
byte[] data)
Implement this method to handle the SSH_MSG_CHANNEL_DATA message. |
protected abstract void |
onChannelEOF(Channel channel)
Implement this method to handle the SSH_MSG_CHANNEL_EOF message. |
protected abstract void |
onChannelExtData(Channel channel,
byte[] data)
Implement this methos to handle the SSH_MSG_CHANNEL_EXT_DATA message. |
protected abstract boolean |
onChannelOpen(Channel channel,
byte[] channelData)
Implements this method to handle the SSH_MSG_CHANNEL_OPEN message. |
protected abstract void |
onChannelRequest(Channel channel,
java.lang.String requestType,
boolean wantReply,
byte[] requestData)
Implement this method to handle the SSH_MSG_CHANNEL_REQUEST message. |
protected abstract void |
onGlobalRequest(java.lang.String requestName,
boolean wantReply,
byte[] requestData)
Implement this method to handle the SSH_MSG_GLOBAL_REQUEST message. |
protected abstract void |
onGlobalRequestFailure()
Implements this method to handle the SSH_MSG_REQUEST_FAILURE message. |
protected abstract void |
onGlobalRequestSuccess(byte[] requestData)
Implement this method to handle the SSH_MSG_REQUEST_SUCCESS message. |
void |
onMessageReceived(SshMessage msg)
Implements the abstract method to handle the registered message notifications. |
void |
onServiceInit()
Called by the framework once the service has been accepted or requested. |
protected Channel |
openChannel(java.lang.String channelName,
java.lang.String channelType,
long initialWindowSize,
long maximumPacketSize,
byte[] channelData)
Syncrhonously opens a channel by sending the SSH_MSG_CHANNEL_OPEN message and waits for either the SSH_MSG_CHANNEL_OPEN_FAILURE or SSH_MSG_CHANNEL_OPEN_CONFIRMATION messages. |
protected void |
sendChannelData(Channel channel,
byte[] data)
Sends data to the channel using the SSH_MSG_CHANNEL_DATA. |
protected void |
sendChannelEOF(Channel channel)
Sets the local channel as End Of File by sending the SSH_MSG_CHANNEL_EOF message. |
protected void |
sendChannelExtData(Channel channel,
byte[] data)
Sends data to the channel using the SSH_MSG_CHANNEL_EXT_DATA. |
protected void |
sendChannelFailure(Channel channel)
Sends the SSH_MSG_CHANNEL_FAILURE message. |
protected void |
sendChannelOpenConfirmation(Channel channel,
byte[] channelData)
Sends the SSH_MSG_CHANNEL_OPEN_CONFIRMATION message. |
protected void |
sendChannelOpenFailure(Channel channel,
long reasonCode,
java.lang.String additionalInfo,
java.lang.String languageTag)
Sends the SSH_MSG_CHANNEL_OPEN_FAILURE message. |
protected boolean |
sendChannelRequest(Channel channel,
java.lang.String requestType,
boolean wantReply,
byte[] requestData)
Sends the SSH_MSG_CHANNEL_REQUEST message. |
protected void |
sendChannelSuccess(Channel channel)
Sends the SSH_MSG_CHANNEL_SUCCES message. |
protected void |
sendChannelWindowAdjust(Channel channel,
long bytesToAdd)
Sends the SSH_MSG_CHANNEL_WINDOW_ADJUST message. |
protected void |
sendGlobalRequest(java.lang.String requestName,
boolean wantReply,
byte[] requestData)
Sends the connection protocol message SSH_MSG_GLOBAL_REQUEST. |
protected void |
sendGlobalRequestFailure()
Sends the connection protocol message SSH_MSG_REQUEST_FAILURE. |
protected void |
sendGlobalRequestSuccess(byte[] requestData)
Sends the connection protocol message SSH_MSG_REQUEST_SUCCESS. |
Methods inherited from class com.sshtools.j2ssh.transport.Service |
getExchangeHash, getMessageStore, getServiceName, getTransportLayer, onDisconnect, onServiceAccept, onServiceRequest, onThreadException, run, start, stop, waitForSingleMessage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ConnectionProtocol()
Method Detail |
public void onServiceInit() throws ServiceOperationException
Called by the framework once the service has been accepted or requested.
onServiceInit
in class Service
ServiceOperationException
protected void sendGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData) throws TransportProtocolException
Sends the connection protocol message SSH_MSG_GLOBAL_REQUEST.
requestName
- The request namewantReply
- Whether a reply is neededrequestData
- The request specific data
TransportProtocolException
protected void sendGlobalRequestSuccess(byte[] requestData) throws TransportProtocolException
Sends the connection protocol message SSH_MSG_REQUEST_SUCCESS.
requestData
- The request specific data
TransportProtocolException
protected void sendGlobalRequestFailure() throws TransportProtocolException
Sends the connection protocol message SSH_MSG_REQUEST_FAILURE.
TransportProtocolException
protected Channel openChannel(java.lang.String channelName, java.lang.String channelType, long initialWindowSize, long maximumPacketSize, byte[] channelData) throws TransportProtocolException, ServiceOperationException
Syncrhonously opens a channel by sending the SSH_MSG_CHANNEL_OPEN message and waits for either the SSH_MSG_CHANNEL_OPEN_FAILURE or SSH_MSG_CHANNEL_OPEN_CONFIRMATION messages. If the request succeeds the Channel instance os returned, otherwise the method returns null.
channelName
- The descriptive name for the
channelchannelType
- The SSH channel type (i.e.
;session')initialWindowSize
- The initial window size requiredmaximumPacketSize
- The maximum packet size requiredchannelData
- Channel specific request data
TransportProtocolException
ServiceOperationException
- Description of the Exceptionprotected void sendChannelOpenConfirmation(Channel channel, byte[] channelData) throws TransportProtocolException
Sends the SSH_MSG_CHANNEL_OPEN_CONFIRMATION message.
channel
- The channel to confirm openchannelData
- Channel specific data
TransportProtocolException
protected void sendChannelOpenFailure(Channel channel, long reasonCode, java.lang.String additionalInfo, java.lang.String languageTag) throws TransportProtocolException
Sends the SSH_MSG_CHANNEL_OPEN_FAILURE message.
channel
- The channel to inform of failurereasonCode
- The reason codeadditionalInfo
- Additional informationlanguageTag
- The language tag
TransportProtocolException
protected void closeChannel(Channel channel) throws TransportProtocolException
Closes the channel by sending the SSH_MSG_CHANNEL_CLOSE message.
channel
- The channel to close
TransportProtocolException
protected void sendChannelEOF(Channel channel) throws TransportProtocolException
Sets the local channel as End Of File by sending the SSH_MSG_CHANNEL_EOF message.
channel
- The channel to set EOF
TransportProtocolException
protected void sendChannelData(Channel channel, byte[] data) throws WindowSpaceNotAvailableException, TransportProtocolException
Sends data to the channel using the SSH_MSG_CHANNEL_DATA.
channel
- The channel to send data
overdata
- The data to send
TransportProtocolException
WindowSpaceNotAvailableException
- Description of the Exceptionprotected void sendChannelExtData(Channel channel, byte[] data) throws WindowSpaceNotAvailableException, TransportProtocolException
Sends data to the channel using the SSH_MSG_CHANNEL_EXT_DATA.
channel
- The channel to send data
throughdata
- The data channel
TransportProtocolException
WindowSpaceNotAvailableException
- Description of the Exceptionprotected void sendChannelFailure(Channel channel) throws TransportProtocolException
Sends the SSH_MSG_CHANNEL_FAILURE message.
channel
- The failed channel
TransportProtocolException
protected void sendChannelWindowAdjust(Channel channel, long bytesToAdd) throws TransportProtocolException
Sends the SSH_MSG_CHANNEL_WINDOW_ADJUST message.
channel
- The channel to sendbytesToAdd
- The number of bytes to add to the
window space
TransportProtocolException
protected void sendChannelSuccess(Channel channel) throws TransportProtocolException
Sends the SSH_MSG_CHANNEL_SUCCES message.
channel
- The channel
TransportProtocolException
protected boolean sendChannelRequest(Channel channel, java.lang.String requestType, boolean wantReply, byte[] requestData) throws TransportProtocolException, ServiceOperationException
Sends the SSH_MSG_CHANNEL_REQUEST message.
channel
- The channel for the requestrequestType
- The channel request typewantReply
- Whether a reply is neededrequestData
- The request specific data
TransportProtocolException
ServiceOperationException
- Description of the Exceptionpublic void onMessageReceived(SshMessage msg) throws ServiceOperationException, TransportProtocolException
Implements the abstract method to handle the registered message notifications.
onMessageReceived
in class Service
msg
- The message received
ServiceOperationException
TransportProtocolException
protected abstract void onGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData) throws ServiceOperationException
Implement this method to handle the SSH_MSG_GLOBAL_REQUEST message.
requestName
- The name of the requestwantReply
- True is the remote computer wants a
reply. Use sendGlobalRequestSuccess
or sendGlobalRequestFailure
requestData
- Request specific data
ServiceOperationException
- Throw for any exceptionsprotected abstract void onGlobalRequestSuccess(byte[] requestData) throws ServiceOperationException
Implement this method to handle the SSH_MSG_REQUEST_SUCCESS message.
requestData
- Request specific data
ServiceOperationException
- Throw for any exceptionsprotected abstract void onGlobalRequestFailure() throws ServiceOperationException
Implements this method to handle the SSH_MSG_REQUEST_FAILURE message.
ServiceOperationException
- Throw for any exceptionsprotected abstract boolean onChannelOpen(Channel channel, byte[] channelData) throws ServiceOperationException
Implements this method to handle the SSH_MSG_CHANNEL_OPEN message. Use
sendChannelOpenConfirmation
or sendChannelOpenFailure
methods to respond.
channel
- The channel to be openedchannelData
- Channel specific data
ServiceOperationException
- Throw for any exceptionsprotected abstract void onChannelClose(Channel channel) throws ServiceOperationException
Implement this method to handle the SSH_MSG_CHANNEL_CLOSE message.
channel
- The channel being closed
ServiceOperationException
- Throw for any exceptionsprotected abstract void onChannelEOF(Channel channel) throws ServiceOperationException
Implement this method to handle the SSH_MSG_CHANNEL_EOF message.
channel
- The channel being set to EOF
ServiceOperationException
- Throw for any exceptionsprotected abstract void onChannelRequest(Channel channel, java.lang.String requestType, boolean wantReply, byte[] requestData) throws ServiceOperationException
Implement this method to handle the SSH_MSG_CHANNEL_REQUEST message.
channel
- The channel for the requestrequestType
- The request typewantReply
- true if the remote side requires a
reply Use sendChannelRequestSuccess
or sendChannelRequestFailure
requestData
- The request specific data
ServiceOperationException
- Throw for any exceptionsprotected abstract void onChannelData(Channel channel, byte[] data) throws ServiceOperationException
Implement this method to handle the SSH_MSG_CHANNEL_DATA message.
channel
- The data's channeldata
- The data
ServiceOperationException
- Throw for ant exceptionsprotected abstract void onChannelExtData(Channel channel, byte[] data) throws ServiceOperationException
Implement this methos to handle the SSH_MSG_CHANNEL_EXT_DATA message.
channel
- The data's channeldata
- The data
ServiceOperationException
- Throw for any exceptions
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |