com.monica.javacom.ssh
Class MJCSSHTransportLayer

java.lang.Object
  |
  +--com.monica.javacom.ssh.MJCSSHTransportLayer
All Implemented Interfaces:
MJCCloser, MJCConfigureable, MJCReadable, MJCReader, MJCWriteable, MJCWriter, java.lang.Runnable

public class MJCSSHTransportLayer
extends java.lang.Object
implements MJCReader, MJCWriter, MJCReadable, MJCWriteable, MJCConfigureable, MJCCloser, java.lang.Runnable

This is the main class for the MCJ SSH2 layer. It provides functionality for the transport, authentication and connection layers of SSH2. This class is compliand to the MJC layer hierarchy and can be placed between the MJCTerminal and the MJCTransport layers. It provides both MJCProtocol and MJCCiphering functionality in the means of the MJC layer hierarchy.


Constructor Summary
MJCSSHTransportLayer()
           
 
Method Summary
 void closeApplication()
          This method closes the client side application.
 void connectionClosedEvent(MJCReadable readable)
          Indicates that the source connection of the specified MJCReadable has been closed.
 void errorEvent(java.lang.String errorDesc, MJCReadable readable)
          Indicates that there was an error in the source connection of the specified MJCReadable.
 void flush()
          Flushes the contents of the write buffer to bottom layers.
 int getAvailable()
          Returns the number of bytes that are available for read out from this MJCReadable.
 java.lang.String getCloserName()
          Returns the MJC name of the MJCCloser.
 java.lang.String getCloserVersion()
          Returns the MJC version of the MJCCloser.
 MJCConfiguration getConfiguration()
          Returns the MJCConfiguration with which this object is customized.
 java.lang.String getInput()
          Returns the contents of the read buffer from this MJCReadable.
 java.lang.String getLastWriteableError()
          Returns the error message of the last occured error.
 MJCReadable getReadable()
          Returns the MJCReadable from which data will be read.
 java.lang.String getReadableName()
          Returns the MJC name of the MJCReadable.
 java.lang.String getReadableVersion()
          Returns the MJC version of the MJCReadable.
 MJCReader getReader()
          Returns the MJCReader to which readEvents will be sent.
 java.lang.String getReaderName()
          Returns the MJC name of the MJCReader.
 java.lang.String getReaderVersion()
          Returns the MJC version of the MJCReader.
 MJCWriteable getWriteable()
          Returns the MJCWriteable to which this MCJWriter will write.
 java.lang.String getWriteableName()
          Returns the MJC name of the MJCWriteable.
 java.lang.String getWriteableVersion()
          Returns the MJC version of the MJCWriteable.
 java.lang.String getWriterName()
          Returns the MJC name of the MJCWriter.
 java.lang.String getWriterVersion()
          Returns the MJC version of the MJCWriter.
 boolean isReadableConnected()
          Returns wether the MJCReadable is still connected to its source.
 boolean isWriteableConnected()
          Returns wether the MJCWriteable is connected to its target.
 void readEvent(MJCReadable readable)
          Indicates that there is data available from the specified MJCReadable.
 void run()
          Entry point for the reader thread.
 void setConfiguration(MJCConfiguration configuration)
          Sets the MJCConfiguration for this object.
 void setReadable(MJCReadable readable)
          Sets the MJCReadable from which data has to be read.
 void setReader(MJCReader reader)
          Sets the MJCReader to which the readEvents have to be sent.
 void setTransport(MJCTransport transport)
          Sets the MJCTransport which is responsible for the data connection between the client and the server.
 void setWindow(MJCWindow window)
          Sets the MJCWindow that represents the user interface of the client side.
 void setWriteable(MJCWriteable writeable)
          Sets the MJCWriteable to which this MJCWriter will write.
 boolean write(char c)
          Writes one single char.
 boolean write(char[] ca)
          Writes a char array.
 boolean write(java.lang.String s)
          Writes a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCSSHTransportLayer

public MJCSSHTransportLayer()
Method Detail

run

public void run()
Entry point for the reader thread.
Specified by:
run in interface java.lang.Runnable

getCloserName

public java.lang.String getCloserName()
Description copied from interface: MJCCloser
Returns the MJC name of the MJCCloser.
Specified by:
getCloserName in interface MJCCloser
Following copied from interface: com.monica.javacom.interfaces.MJCCloser
Returns:
String: the MJC name of the MJCCloser

getCloserVersion

public java.lang.String getCloserVersion()
Description copied from interface: MJCCloser
Returns the MJC version of the MJCCloser.
Specified by:
getCloserVersion in interface MJCCloser
Following copied from interface: com.monica.javacom.interfaces.MJCCloser
Returns:
String: the MJC version of the MJCCloser

closeApplication

public void closeApplication()
Description copied from interface: MJCCloser
This method closes the client side application.
Specified by:
closeApplication in interface MJCCloser

setTransport

public void setTransport(MJCTransport transport)
Description copied from interface: MJCCloser
Sets the MJCTransport which is responsible for the data connection between the client and the server.
Specified by:
setTransport in interface MJCCloser
Following copied from interface: com.monica.javacom.interfaces.MJCCloser
Parameters:
MJCTransport - transport: the MJCTransport that is responsible for the data connection between client and server

setWindow

public void setWindow(MJCWindow window)
Description copied from interface: MJCCloser
Sets the MJCWindow that represents the user interface of the client side.
Specified by:
setWindow in interface MJCCloser
Following copied from interface: com.monica.javacom.interfaces.MJCCloser
Parameters:
MJCWindow - window: the MJCWindow that represents the user interface of the client side

setConfiguration

public void setConfiguration(MJCConfiguration configuration)
Description copied from interface: MJCConfigureable
Sets the MJCConfiguration for this object.
Specified by:
setConfiguration in interface MJCConfigureable
Following copied from interface: com.monica.javacom.interfaces.MJCConfigureable
Parameters:
MJCConfiguration - configuration: the MJCConfiguration object for the customization

getConfiguration

public MJCConfiguration getConfiguration()
Description copied from interface: MJCConfigureable
Returns the MJCConfiguration with which this object is customized.
Specified by:
getConfiguration in interface MJCConfigureable
Following copied from interface: com.monica.javacom.interfaces.MJCConfigureable
Returns:
MJCConfiguration: the MJCConfiguration with which this object is customized

getReadableName

public java.lang.String getReadableName()
Description copied from interface: MJCReadable
Returns the MJC name of the MJCReadable.
Specified by:
getReadableName in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
String: the MJC name of the MJCReadable

getReadableVersion

public java.lang.String getReadableVersion()
Description copied from interface: MJCReadable
Returns the MJC version of the MJCReadable.
Specified by:
getReadableVersion in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
String: the MJC version of the MJCReadable

getAvailable

public int getAvailable()
Description copied from interface: MJCReadable
Returns the number of bytes that are available for read out from this MJCReadable.
Specified by:
getAvailable in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
int: the number of bytes available for read out

getInput

public java.lang.String getInput()
Description copied from interface: MJCReadable
Returns the contents of the read buffer from this MJCReadable.
Specified by:
getInput in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
String: the contents of the read buffer

isReadableConnected

public boolean isReadableConnected()
Description copied from interface: MJCReadable
Returns wether the MJCReadable is still connected to its source.
Specified by:
isReadableConnected in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
boolean: wether the MJCReadable is still connected to its source

setReader

public void setReader(MJCReader reader)
Description copied from interface: MJCReadable
Sets the MJCReader to which the readEvents have to be sent.
Specified by:
setReader in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Parameters:
MJCReader - reader: the MJCReader to which the readEvents have to be sent

getReader

public MJCReader getReader()
Description copied from interface: MJCReadable
Returns the MJCReader to which readEvents will be sent.
Specified by:
getReader in interface MJCReadable
Following copied from interface: com.monica.javacom.interfaces.MJCReadable
Returns:
MJCReader: the MJCReader to which readEvents will be sent

getWriteableName

public java.lang.String getWriteableName()
Description copied from interface: MJCWriteable
Returns the MJC name of the MJCWriteable.
Specified by:
getWriteableName in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Returns:
String: the MJC name of the MJCWriteable

getWriteableVersion

public java.lang.String getWriteableVersion()
Description copied from interface: MJCWriteable
Returns the MJC version of the MJCWriteable.
Specified by:
getWriteableVersion in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Returns:
String: the MJC version of the MJCWriteable

write

public boolean write(char c)
Description copied from interface: MJCWriteable
Writes one single char. Writing is synchronous and can be buffered.
Specified by:
write in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Parameters:
char - c: the char to be written
Returns:
boolean: wether the writing has been successful

write

public boolean write(char[] ca)
Description copied from interface: MJCWriteable
Writes a char array. Writing is synchronous and can be buffered.
Specified by:
write in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Parameters:
char[] - c: the char array to be written
Returns:
boolean: wether the writing has been successful

write

public boolean write(java.lang.String s)
Description copied from interface: MJCWriteable
Writes a String. Writing is synchronous and can be buffered.
Specified by:
write in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Parameters:
String - s: the String to be written
Returns:
boolean: wether the writing has been successful

flush

public void flush()
Description copied from interface: MJCWriteable
Flushes the contents of the write buffer to bottom layers.
Specified by:
flush in interface MJCWriteable

getLastWriteableError

public java.lang.String getLastWriteableError()
Description copied from interface: MJCWriteable
Returns the error message of the last occured error. After returning it, the error message will be deleted and cannot be queried again.
Specified by:
getLastWriteableError in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Returns:
String: the last error message

isWriteableConnected

public boolean isWriteableConnected()
Description copied from interface: MJCWriteable
Returns wether the MJCWriteable is connected to its target.
Specified by:
isWriteableConnected in interface MJCWriteable
Following copied from interface: com.monica.javacom.interfaces.MJCWriteable
Returns:
boolean: wether the MJCWriteable is connected to its target

getReaderName

public java.lang.String getReaderName()
Description copied from interface: MJCReader
Returns the MJC name of the MJCReader.
Specified by:
getReaderName in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Returns:
String: the MJC name of the MJCReader

getReaderVersion

public java.lang.String getReaderVersion()
Description copied from interface: MJCReader
Returns the MJC version of the MJCReader.
Specified by:
getReaderVersion in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Returns:
String: the MJC version of the MJCReader

readEvent

public void readEvent(MJCReadable readable)
Description copied from interface: MJCReader
Indicates that there is data available from the specified MJCReadable.
Specified by:
readEvent in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Parameters:
MJCReadable - readable: there is data available from the readable

connectionClosedEvent

public void connectionClosedEvent(MJCReadable readable)
Description copied from interface: MJCReader
Indicates that the source connection of the specified MJCReadable has been closed.
Specified by:
connectionClosedEvent in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Parameters:
MJCReadable - readable: the MJCReadable whose source connection has been closed

errorEvent

public void errorEvent(java.lang.String errorDesc,
                       MJCReadable readable)
Description copied from interface: MJCReader
Indicates that there was an error in the source connection of the specified MJCReadable.
Specified by:
errorEvent in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Parameters:
String - errorDescription: the error message
MJCReadable - readable: the MJCReadable where the error occured

setReadable

public void setReadable(MJCReadable readable)
Description copied from interface: MJCReader
Sets the MJCReadable from which data has to be read.
Specified by:
setReadable in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Parameters:
MJCReadable - readable: the MJCReadable from which data has to be read

getReadable

public MJCReadable getReadable()
Description copied from interface: MJCReader
Returns the MJCReadable from which data will be read.
Specified by:
getReadable in interface MJCReader
Following copied from interface: com.monica.javacom.interfaces.MJCReader
Returns:
MJCReadable: the MJCReadable from which data will be read

getWriterName

public java.lang.String getWriterName()
Description copied from interface: MJCWriter
Returns the MJC name of the MJCWriter.
Specified by:
getWriterName in interface MJCWriter
Following copied from interface: com.monica.javacom.interfaces.MJCWriter
Returns:
String: the MJC name of the MJCWriter

getWriterVersion

public java.lang.String getWriterVersion()
Description copied from interface: MJCWriter
Returns the MJC version of the MJCWriter.
Specified by:
getWriterVersion in interface MJCWriter
Following copied from interface: com.monica.javacom.interfaces.MJCWriter
Returns:
String: the MJC version of the MJCWriter

setWriteable

public void setWriteable(MJCWriteable writeable)
Description copied from interface: MJCWriter
Sets the MJCWriteable to which this MJCWriter will write.
Specified by:
setWriteable in interface MJCWriter
Following copied from interface: com.monica.javacom.interfaces.MJCWriter
Parameters:
MJCWriteable - writeable: the MJCWriteable to which this MJCWriter will write

getWriteable

public MJCWriteable getWriteable()
Description copied from interface: MJCWriter
Returns the MJCWriteable to which this MCJWriter will write.
Specified by:
getWriteable in interface MJCWriter
Following copied from interface: com.monica.javacom.interfaces.MJCWriter
Returns:
MJCWriteable: the MJCWriteable to which this MJCWriter will write