com.maverick.sshd
Interface SshMessage


public interface SshMessage

This interface provides a callback for writing SSH messages into the outgoing buffer. When a message is to be sent you should call TransportProtocol.sendMessage(SshMessage) with an implementation of this interface. When the socket is ready for writing and your message is the next available in the outgoing queue your implementation of writeMessageIntoBuffer(ByteBuffer) will be called. You should write the SSH message into the ByteBuffer and return. When the message has been written out to the socket messageSent() will be called.

The following code demonstrates how the interface is used by the transport protocol to send the SSH_MSG_NEWKEYS.

 sendMessage(new SshMessage() {
     public void writeMessageIntoBuffer(ByteBuffer buf) {
         buf.put((byte) TransportProtocol.SSH_MSG_NEWKEYS);
     }
 
     public void messageSent() {
         // Potentially we could generate the keys if we have received SSH_MSG_NEWKEYS
         synchronized (keyExchange) {
             EventLog.LogEvent(this,"Sent SSH_MSG_NEWKEYS");
             keyExchange.sentNewKeys = true;
             generateNewKeys();
         }
     }
 });
 
 

For most server implementations it will not be required to implement this interface. It is essentially for internal use but may be used if you develop a custom authentication mechanism that requires additional messages to be sent to the client

Author:
Lee David Painter

Method Summary
 void messageSent()
           
 boolean writeMessageIntoBuffer(java.nio.ByteBuffer buf)
          Write the SSH message data into a ByteBuffer.
 

Method Detail

writeMessageIntoBuffer

boolean writeMessageIntoBuffer(java.nio.ByteBuffer buf)
Write the SSH message data into a ByteBuffer.

Parameters:
buf -
Returns:
true if no more messages of this type are to be sent, otherwise return false to remain the first in the queue to send more messages of this type.

messageSent

void messageSent()


Copyright © 2003-2008 SSHTools LTD. All Rights Reserved.