Class SshMessage
- Direct Known Subclasses:
SshMsgChannelClose
,SshMsgChannelData
,SshMsgChannelEOF
,SshMsgChannelExtendedData
,SshMsgChannelFailure
,SshMsgChannelOpen
,SshMsgChannelOpenConfirmation
,SshMsgChannelOpenFailure
,SshMsgChannelRequest
,SshMsgChannelSuccess
,SshMsgChannelWindowAdjust
,SshMsgDebug
,SshMsgDisconnect
,SshMsgGlobalRequest
,SshMsgIgnore
,SshMsgKexDhInit
,SshMsgKexDhReply
,SshMsgKexInit
,SshMsgNewKeys
,SshMsgRequestFailure
,SshMsgRequestSuccess
,SshMsgServiceAccept
,SshMsgServiceRequest
,SshMsgUnimplemented
,SshMsgUserAuthBanner
,SshMsgUserAuthFailure
,SshMsgUserAuthInfoRequest
,SshMsgUserAuthInfoResponse
,SshMsgUserAuthPKOK
,SshMsgUserAuthPwdChangeReq
,SshMsgUserAuthRequest
,SshMsgUserAuthSuccess
This class implements the payload portion each message sent by the transport protocol. Each message consists of an integer message id followed by a variable byte array containing message data.
- Since:
- 0.2.0
- Version:
- $Revision: 1.21 $
- Author:
- Lee David Painter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Message implementations should implement this method, writing the data as exected in the transport protocol message format.protected abstract void
Message implementation should implement this method, reading the data as expected in the transport protocol message format.protected final void
fromByteArray
(ByteArrayReader data) Initializes the message from a byte array.final int
Returns the id of the messagestatic Integer
getMessageId
(byte[] msgdata) Helper method to extract the message id from the complete message data recieved by the transport protocol.abstract String
Returns the name of the message implementation for debugging purposes.final byte[]
Format the message into the payload array for sending by the transport protocol.
-
Constructor Details
-
SshMessage
public SshMessage(int messageId) Contructs the message.
- Parameters:
messageId
- the id of the message- Since:
- 0.2.0
-
-
Method Details
-
getMessageId
public final int getMessageId()Returns the id of the message
- Returns:
- an integer message id
- Since:
- 0.2.0
-
getMessageName
Returns the name of the message implementation for debugging purposes.
- Returns:
- the name of the message e.g. "SSH_MSG_DISCONNECT"
- Since:
- 0.2.0
-
toByteArray
Format the message into the payload array for sending by the transport protocol. This implementation creates a byte array, writes the message id and calls the abstract
constructByteArray
.- Returns:
- the payload portion of a transport protocol message
- Throws:
InvalidMessageException
- if the message is invalid- Since:
- 0.2.0
-
fromByteArray
Initializes the message from a byte array.
- Parameters:
data
- the byte array being read.- Throws:
InvalidMessageException
- if the message is invalid- Since:
- 0.2.0
-
getMessageId
Helper method to extract the message id from the complete message data recieved by the transport protocol.
- Parameters:
msgdata
- the transport protocol message- Returns:
- the id of the message
- Since:
- 0.2.0
-
constructByteArray
Message implementations should implement this method, writing the data as exected in the transport protocol message format.
- Parameters:
baw
- the byte array being written to- Throws:
InvalidMessageException
- if the message is invalid- Since:
- 0.2.0
-
constructMessage
Message implementation should implement this method, reading the data as expected in the transport protocol message format.
- Parameters:
bar
- the byte array being read- Throws:
InvalidMessageException
- if the message is invalid- Since:
- 0.2.0
-