Secure iNet Factory

com.jscape.inet.ssh.transport
Class MessageReader

java.lang.Object
  extended by com.jscape.inet.ssh.transport.MessageStream
      extended by com.jscape.inet.ssh.transport.MessageReader

public final class MessageReader
extends MessageStream

The SSH message reader.

Author:
Alex Usun

Constructor Summary
MessageReader(java.io.InputStream in, Compression decompressor, javax.crypto.Cipher cipher, javax.crypto.Mac mac)
          Creates a new in instance.
 
Method Summary
 void close()
          Closes the reader.
 boolean isMacCheckAllowed()
          Checks if the SSH messages MAC verification is turned on.
 boolean knowsMessage(int type)
           
 java.lang.String readLine()
          Reads a string line.
 Message readMessage()
          Reads incoming message from the underlayed input stream.
 void registerMessage(int type, java.lang.Class messageClass)
           
 void setCipher(javax.crypto.Cipher cipher)
          Setups the current stream cipher.
 void setMacCheckAllowed(boolean macCheckAllowed)
          Setups the SSH messages MAC verification.
 void unregisterMessage(int type)
           
 
Methods inherited from class com.jscape.inet.ssh.transport.MessageStream
getBytesCount, setCompression, setMac
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageReader

public MessageReader(java.io.InputStream in,
                     Compression decompressor,
                     javax.crypto.Cipher cipher,
                     javax.crypto.Mac mac)
Creates a new in instance.

Parameters:
in - the target input stream
decompressor - the message compression
cipher - the message cipher
mac - the message MAC
Method Detail

setCipher

public void setCipher(javax.crypto.Cipher cipher)
Description copied from class: MessageStream
Setups the current stream cipher.

Overrides:
setCipher in class MessageStream
Parameters:
cipher - the current stream cipher
See Also:
MessageStream.setCipher(javax.crypto.Cipher)

isMacCheckAllowed

public boolean isMacCheckAllowed()
Checks if the SSH messages MAC verification is turned on. By default this feature is enabled.

Returns:
true if the MAC verification is turned on; false otherwise

setMacCheckAllowed

public void setMacCheckAllowed(boolean macCheckAllowed)
Setups the SSH messages MAC verification.

Parameters:
macCheckAllowed - if true the MAC verification will be turned on

registerMessage

public void registerMessage(int type,
                            java.lang.Class messageClass)
Parameters:
type -
messageClass -

unregisterMessage

public void unregisterMessage(int type)
Parameters:
type -

knowsMessage

public boolean knowsMessage(int type)
Parameters:
type -
Returns:
knows message

close

public void close()
Closes the reader.


readLine

public java.lang.String readLine()
                          throws java.io.IOException
Reads a string line.

Returns:
a readed line
Throws:
java.io.IOException - if an I/O error occurs

readMessage

public Message readMessage()
                    throws java.io.IOException
Reads incoming message from the underlayed input stream.

Returns:
the readed message
Throws:
java.io.IOException - if an I/O error occurs
TransportException - if MAC verification error occurs

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved