Class SshMessage

    • Constructor Summary

      Constructors 
      Constructor Description
      SshMessage​(int messageId)
      Contructs the message.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void constructByteArray​(ByteArrayWriter baw)
      Message implementations should implement this method, writing the data as exected in the transport protocol message format.
      protected abstract void constructMessage​(ByteArrayReader bar)
      Message implementation should implement this method, reading the data as expected in the transport protocol message format.
      protected void fromByteArray​(ByteArrayReader data)
      Initializes the message from a byte array.
      int getMessageId()
      Returns the id of the message
      static java.lang.Integer getMessageId​(byte[] msgdata)
      Helper method to extract the message id from the complete message data recieved by the transport protocol.
      abstract java.lang.String getMessageName()
      Returns the name of the message implementation for debugging purposes.
      byte[] toByteArray()
      Format the message into the payload array for sending by the transport protocol.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SshMessage

        public SshMessage​(int messageId)

        Contructs the message.

        Parameters:
        messageId - the id of the message
        Since:
        0.2.0
    • Method Detail

      • getMessageId

        public final int getMessageId()

        Returns the id of the message

        Returns:
        an integer message id
        Since:
        0.2.0
      • getMessageName

        public abstract java.lang.String 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

        public final byte[] toByteArray()
                                 throws InvalidMessageException

        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
      • getMessageId

        public static java.lang.Integer getMessageId​(byte[] msgdata)

        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

        protected abstract void constructByteArray​(ByteArrayWriter baw)
                                            throws InvalidMessageException

        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

        protected abstract void constructMessage​(ByteArrayReader bar)
                                          throws InvalidMessageException

        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