com.monica.javacom.ssh
Class MJCSSHTransportPackageTokenizer

java.lang.Object
  |
  +--com.monica.javacom.ssh.MJCSSHTransportPackageTokenizer

public class MJCSSHTransportPackageTokenizer
extends java.lang.Object

Class for providing functionality to create and receive SSH2 packets. This class is able to create according to the specified MAC and Ciphering algorithms packets from the given payload, and is also able to read SSH2 packets from the given String stream, by using MAC and Ciphering.


Constructor Summary
MJCSSHTransportPackageTokenizer()
          Default constructor.
 
Method Summary
 void arrived(java.lang.String s)
          This method tells this object that at the to be processsed stream new data has arrived.
 java.lang.String createPackage(java.lang.String payload)
          Creates an encrypted, MAC-ed, compressed SSH2 transport packet from the supplied payload and returns it as a String.
 java.lang.String getLastError()
          Returns the description of the last occured error.
 MJCSSHTransportPackage getNextPackage()
          Returns the next available packet from the processed packets.
 boolean isAvailable()
          Returns true if there are processed packets that can be retrieved.
 void setCipherAlgorithm(MJCSSHCipherAlgorithm ca, boolean dir)
          Sets the Cipheralgorithm that has to be used.
 void setCompressionAlgorithm(MJCSSHCompressionAlgorithm ca, boolean dir)
          Sets the Compression algorithm that has to be used.
 void setKeys(java.lang.String iv, java.lang.String ek, java.lang.String ik, boolean dir)
          Sets the keys for encryption (iv, key) and integrity.
 void setMACAlgorithm(MJCSSHMACAlgorithm ma, boolean dir)
          Sets the MAC algorithm that has to be used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCSSHTransportPackageTokenizer

public MJCSSHTransportPackageTokenizer()
Default constructor.
Method Detail

setKeys

public void setKeys(java.lang.String iv,
                    java.lang.String ek,
                    java.lang.String ik,
                    boolean dir)
Sets the keys for encryption (iv, key) and integrity. This method has to be called before the setCipherAlgorithm, setCompressionAlgorithm and setMACAlgorithm methods.
Parameters:
String - iv: the initialization vector for ciphering
String - ek: the encryption key
String - ik: the integrity key (for MAC)
boolean - dir: true for client to server, false for server to client

setMACAlgorithm

public void setMACAlgorithm(MJCSSHMACAlgorithm ma,
                            boolean dir)
Sets the MAC algorithm that has to be used.
Parameters:
MJCSSHMACAlgorithm: - the MAC algorithm to be used
boolean - dir: true for client to server, false for server to client

setCipherAlgorithm

public void setCipherAlgorithm(MJCSSHCipherAlgorithm ca,
                               boolean dir)
Sets the Cipheralgorithm that has to be used.
Parameters:
MJCSSCipherAlgorithm: - the Cipher algorithm to be used
boolean - dir: true for client to server, false for server to client

setCompressionAlgorithm

public void setCompressionAlgorithm(MJCSSHCompressionAlgorithm ca,
                                    boolean dir)
Sets the Compression algorithm that has to be used.
Parameters:
MJCSSHCompressionAlgorithm: - the MAC algorithm to be used
boolean - dir: true for client to server, false for server to client

arrived

public void arrived(java.lang.String s)
             throws java.lang.Exception
This method tells this object that at the to be processsed stream new data has arrived.
Parameters:
String - s: the arrived data
Throws:
Exception: - if there has been an Exception during the processing of the arrived data

isAvailable

public boolean isAvailable()
Returns true if there are processed packets that can be retrieved.
Returns:
boolean: true if there processed packets that can be retrieved

getNextPackage

public MJCSSHTransportPackage getNextPackage()
Returns the next available packet from the processed packets.
Returns:
MJCSSHTransportPackage: the next packet from the processed packets or null if there aren't any

getLastError

public java.lang.String getLastError()
Returns the description of the last occured error. By calling this method the error description will be lost.
Returns:
String: the last occured error

createPackage

public java.lang.String createPackage(java.lang.String payload)
Creates an encrypted, MAC-ed, compressed SSH2 transport packet from the supplied payload and returns it as a String.
Parameters:
String - payload: the packet payload
Returns:
String: the full SSH2 transport packet