com.sshtools.j2ssh.transport
Class TransportProtocolCommon

java.lang.Object
  extended by com.sshtools.j2ssh.transport.TransportProtocolCommon
All Implemented Interfaces:
com.sshtools.j2ssh.transport.TransportProtocol, Runnable
Direct Known Subclasses:
TransportProtocolClient

public abstract class TransportProtocolCommon
extends Object
implements com.sshtools.j2ssh.transport.TransportProtocol, Runnable

DOCUMENT ME!

Version:
$Revision: 1.1 $
Author:
$author$

Field Summary
protected  com.sshtools.j2ssh.transport.TransportProtocolAlgorithmSync algorithmsIn
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.TransportProtocolAlgorithmSync algorithmsOut
          DOCUMENT ME!
protected  String clientIdent
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.SshMsgKexInit clientKexInit
          DOCUMENT ME!
protected  Boolean completeOnNewKeys
          DOCUMENT ME!
static int EOL_CRLF
          DOCUMENT ME!
static int EOL_LF
          DOCUMENT ME!
protected  byte[] hostKey
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.HostKeyVerification hosts
          DOCUMENT ME!
protected  BigInteger k
          DOCUMENT ME!
protected  Map kexs
          DOCUMENT ME!
protected static org.apache.commons.logging.Log log
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.SshMessageStore messageStore
          DOCUMENT ME!
protected  com.sshtools.j2ssh.configuration.SshConnectionProperties properties
          DOCUMENT ME!
static String PROTOCOL_VERSION
          DOCUMENT ME!
protected  String serverIdent
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.SshMsgKexInit serverKexInit
          DOCUMENT ME!
protected  byte[] sessionIdentifier
          DOCUMENT ME!
protected  byte[] signature
          DOCUMENT ME!
static String SOFTWARE_VERSION_COMMENTS
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.TransportProtocolInputStream sshIn
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.TransportProtocolOutputStream sshOut
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.TransportProtocolState state
          DOCUMENT ME!
 
Constructor Summary
TransportProtocolCommon()
          Creates a new TransportProtocolCommon object.
 
Method Summary
 void addEventHandler(com.sshtools.j2ssh.transport.TransportProtocolEventHandler eventHandler)
          DOCUMENT ME!
 void addMessageStore(com.sshtools.j2ssh.transport.SshMessageStore store)
          DOCUMENT ME!
protected  void beginKeyExchange()
          DOCUMENT ME!
protected  void completeKeyExchange()
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.SshMsgKexInit createLocalKexInit()
          DOCUMENT ME!
protected  String determineAlgorithm(List clientAlgorithms, List serverAlgorithms)
          DOCUMENT ME!
 void disconnect(String description)
          DOCUMENT ME!
 int getConnectionId()
          DOCUMENT ME!
protected abstract  String getDecryptionAlgorithm()
          DOCUMENT ME!
protected abstract  String getEncryptionAlgorithm()
          DOCUMENT ME!
protected  List getEventHandlers()
          DOCUMENT ME!
 long getIncomingByteCount()
          DOCUMENT ME!
protected abstract  String getInputStreamCompAlgortihm()
          DOCUMENT ME!
protected abstract  String getInputStreamMacAlgorithm()
          DOCUMENT ME!
protected  String getKexAlgorithm()
          DOCUMENT ME!
abstract  String getLocalId()
          DOCUMENT ME!
protected abstract  com.sshtools.j2ssh.transport.SshMsgKexInit getLocalKexInit()
          DOCUMENT ME!
 long getOutgoingByteCount()
           
protected abstract  String getOutputStreamCompAlgorithm()
          DOCUMENT ME!
protected abstract  String getOutputStreamMacAlgorithm()
          DOCUMENT ME!
 com.sshtools.j2ssh.configuration.SshConnectionProperties getProperties()
          DOCUMENT ME!
 int getRemoteEOL()
          DOCUMENT ME!
abstract  String getRemoteId()
          DOCUMENT ME!
protected abstract  com.sshtools.j2ssh.transport.SshMsgKexInit getRemoteKexInit()
          DOCUMENT ME!
 byte[] getSessionIdentifier()
          DOCUMENT ME!
 com.sshtools.j2ssh.transport.TransportProtocolState getState()
          DOCUMENT ME!
 String getUnderlyingProviderDetail()
          DOCUMENT ME!
protected  void onCorruptMac()
          DOCUMENT ME!
protected abstract  void onDisconnect()
          DOCUMENT ME!
protected abstract  void onMessageReceived(com.sshtools.j2ssh.transport.SshMessage msg)
          DOCUMENT ME!
protected abstract  void onStartTransportProtocol()
          DOCUMENT ME!
protected abstract  void performKeyExchange(com.sshtools.j2ssh.transport.kex.SshKeyExchange kex)
          DOCUMENT ME!
protected  com.sshtools.j2ssh.transport.SshMessage processMessages()
          DOCUMENT ME!
 com.sshtools.j2ssh.transport.SshMessage readMessage(int[] filter)
          DOCUMENT ME!
abstract  void registerTransportMessages()
          DOCUMENT ME!
 void removeMessageStore(com.sshtools.j2ssh.transport.SshMessageStore ms)
          DOCUMENT ME!
 void run()
          DOCUMENT ME!
protected  void sendDisconnect(int reason, String description)
          DOCUMENT ME!
protected  void sendDisconnect(int reason, String description, IOException error)
          DOCUMENT ME!
protected  void sendKeyExchangeInit()
          DOCUMENT ME!
 void sendMessage(com.sshtools.j2ssh.transport.SshMessage msg, Object sender)
          DOCUMENT ME!
protected  void sendNewKeys()
          DOCUMENT ME!
 void setKexTimeout(long seconds)
          DOCUMENT ME!
 void setKexTransferLimit(long kilobytes)
          DOCUMENT ME!
protected abstract  void setLocalIdent()
          DOCUMENT ME!
protected abstract  void setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
          DOCUMENT ME!
protected abstract  void setRemoteIdent(String ident)
          DOCUMENT ME!
protected abstract  void setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
          DOCUMENT ME!
 void setSendIgnore(boolean sendIgnore)
          DOCUMENT ME!
protected abstract  void setupNewKeys(byte[] encryptCSKey, byte[] encryptCSIV, byte[] encryptSCKey, byte[] encryptSCIV, byte[] macCSKey, byte[] macSCKey)
          DOCUMENT ME!
protected  void startBinaryPacketProtocol()
          DOCUMENT ME!
 void startTransportProtocol(com.sshtools.j2ssh.net.TransportProvider provider, com.sshtools.j2ssh.configuration.SshConnectionProperties properties)
          DOCUMENT ME!
protected  void stop()
          DOCUMENT ME!
 void unregisterMessage(Integer messageId, com.sshtools.j2ssh.transport.SshMessageStore store)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
DOCUMENT ME!


EOL_CRLF

public static final int EOL_CRLF
DOCUMENT ME!

See Also:
Constant Field Values

EOL_LF

public static final int EOL_LF
DOCUMENT ME!

See Also:
Constant Field Values

PROTOCOL_VERSION

public static final String PROTOCOL_VERSION
DOCUMENT ME!

See Also:
Constant Field Values

SOFTWARE_VERSION_COMMENTS

public static String SOFTWARE_VERSION_COMMENTS
DOCUMENT ME!


k

protected BigInteger k
DOCUMENT ME!


completeOnNewKeys

protected Boolean completeOnNewKeys
DOCUMENT ME!


hosts

protected com.sshtools.j2ssh.transport.HostKeyVerification hosts
DOCUMENT ME!


kexs

protected Map kexs
DOCUMENT ME!


properties

protected com.sshtools.j2ssh.configuration.SshConnectionProperties properties
DOCUMENT ME!


messageStore

protected com.sshtools.j2ssh.transport.SshMessageStore messageStore
DOCUMENT ME!


clientKexInit

protected com.sshtools.j2ssh.transport.SshMsgKexInit clientKexInit
DOCUMENT ME!


serverKexInit

protected com.sshtools.j2ssh.transport.SshMsgKexInit serverKexInit
DOCUMENT ME!


clientIdent

protected String clientIdent
DOCUMENT ME!


serverIdent

protected String serverIdent
DOCUMENT ME!


algorithmsIn

protected com.sshtools.j2ssh.transport.TransportProtocolAlgorithmSync algorithmsIn
DOCUMENT ME!


algorithmsOut

protected com.sshtools.j2ssh.transport.TransportProtocolAlgorithmSync algorithmsOut
DOCUMENT ME!


state

protected com.sshtools.j2ssh.transport.TransportProtocolState state
DOCUMENT ME!


sessionIdentifier

protected byte[] sessionIdentifier
DOCUMENT ME!


hostKey

protected byte[] hostKey
DOCUMENT ME!


signature

protected byte[] signature
DOCUMENT ME!


sshIn

protected com.sshtools.j2ssh.transport.TransportProtocolInputStream sshIn
DOCUMENT ME!


sshOut

protected com.sshtools.j2ssh.transport.TransportProtocolOutputStream sshOut
DOCUMENT ME!

Constructor Detail

TransportProtocolCommon

public TransportProtocolCommon()
Creates a new TransportProtocolCommon object.

Method Detail

getConnectionId

public int getConnectionId()
DOCUMENT ME!

Specified by:
getConnectionId in interface com.sshtools.j2ssh.transport.TransportProtocol
Returns:
DOCUMENT ME!

getRemoteEOL

public int getRemoteEOL()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getState

public com.sshtools.j2ssh.transport.TransportProtocolState getState()
DOCUMENT ME!

Specified by:
getState in interface com.sshtools.j2ssh.transport.TransportProtocol
Returns:
DOCUMENT ME!

getProperties

public com.sshtools.j2ssh.configuration.SshConnectionProperties getProperties()
DOCUMENT ME!

Returns:
DOCUMENT ME!

onDisconnect

protected abstract void onDisconnect()
DOCUMENT ME!


disconnect

public void disconnect(String description)
DOCUMENT ME!

Specified by:
disconnect in interface com.sshtools.j2ssh.transport.TransportProtocol
Parameters:
description - DOCUMENT ME!

setSendIgnore

public void setSendIgnore(boolean sendIgnore)
DOCUMENT ME!

Parameters:
sendIgnore - DOCUMENT ME!

setKexTimeout

public void setKexTimeout(long seconds)
                   throws com.sshtools.j2ssh.transport.TransportProtocolException
DOCUMENT ME!

Parameters:
seconds - DOCUMENT ME!
Throws:
TransportProtocolException - DOCUMENT ME!

setKexTransferLimit

public void setKexTransferLimit(long kilobytes)
                         throws com.sshtools.j2ssh.transport.TransportProtocolException
DOCUMENT ME!

Parameters:
kilobytes - DOCUMENT ME!
Throws:
TransportProtocolException - DOCUMENT ME!

getOutgoingByteCount

public long getOutgoingByteCount()

getIncomingByteCount

public long getIncomingByteCount()
DOCUMENT ME!

Returns:
DOCUMENT ME!

addEventHandler

public void addEventHandler(com.sshtools.j2ssh.transport.TransportProtocolEventHandler eventHandler)
DOCUMENT ME!

Parameters:
eventHandler - DOCUMENT ME!

registerTransportMessages

public abstract void registerTransportMessages()
                                        throws com.sshtools.j2ssh.transport.MessageAlreadyRegisteredException
DOCUMENT ME!

Throws:
MessageAlreadyRegisteredException - DOCUMENT ME!

getSessionIdentifier

public byte[] getSessionIdentifier()
DOCUMENT ME!

Specified by:
getSessionIdentifier in interface com.sshtools.j2ssh.transport.TransportProtocol
Returns:
DOCUMENT ME!

run

public void run()
DOCUMENT ME!

Specified by:
run in interface Runnable

sendMessage

public void sendMessage(com.sshtools.j2ssh.transport.SshMessage msg,
                        Object sender)
                 throws IOException
DOCUMENT ME!

Specified by:
sendMessage in interface com.sshtools.j2ssh.transport.TransportProtocol
Parameters:
msg - DOCUMENT ME!
sender - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!
TransportProtocolException - DOCUMENT ME!

onStartTransportProtocol

protected abstract void onStartTransportProtocol()
                                          throws IOException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!

startTransportProtocol

public void startTransportProtocol(com.sshtools.j2ssh.net.TransportProvider provider,
                                   com.sshtools.j2ssh.configuration.SshConnectionProperties properties)
                            throws IOException
DOCUMENT ME!

Parameters:
provider - DOCUMENT ME!
properties - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

getUnderlyingProviderDetail

public String getUnderlyingProviderDetail()
DOCUMENT ME!

Specified by:
getUnderlyingProviderDetail in interface com.sshtools.j2ssh.transport.TransportProtocol
Returns:
DOCUMENT ME!

unregisterMessage

public void unregisterMessage(Integer messageId,
                              com.sshtools.j2ssh.transport.SshMessageStore store)
                       throws com.sshtools.j2ssh.transport.MessageNotRegisteredException
DOCUMENT ME!

Parameters:
messageId - DOCUMENT ME!
store - DOCUMENT ME!
Throws:
MessageNotRegisteredException - DOCUMENT ME!

getDecryptionAlgorithm

protected abstract String getDecryptionAlgorithm()
                                          throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

getEncryptionAlgorithm

protected abstract String getEncryptionAlgorithm()
                                          throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

getInputStreamCompAlgortihm

protected abstract String getInputStreamCompAlgortihm()
                                               throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

getInputStreamMacAlgorithm

protected abstract String getInputStreamMacAlgorithm()
                                              throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

setLocalIdent

protected abstract void setLocalIdent()
DOCUMENT ME!


getLocalId

public abstract String getLocalId()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setLocalKexInit

protected abstract void setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
DOCUMENT ME!

Parameters:
msg - DOCUMENT ME!

getLocalKexInit

protected abstract com.sshtools.j2ssh.transport.SshMsgKexInit getLocalKexInit()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getOutputStreamCompAlgorithm

protected abstract String getOutputStreamCompAlgorithm()
                                                throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

getOutputStreamMacAlgorithm

protected abstract String getOutputStreamMacAlgorithm()
                                               throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

setRemoteIdent

protected abstract void setRemoteIdent(String ident)
DOCUMENT ME!

Parameters:
ident - DOCUMENT ME!

getRemoteId

public abstract String getRemoteId()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setRemoteKexInit

protected abstract void setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
DOCUMENT ME!

Parameters:
msg - DOCUMENT ME!

getRemoteKexInit

protected abstract com.sshtools.j2ssh.transport.SshMsgKexInit getRemoteKexInit()
DOCUMENT ME!

Returns:
DOCUMENT ME!

performKeyExchange

protected abstract void performKeyExchange(com.sshtools.j2ssh.transport.kex.SshKeyExchange kex)
                                    throws IOException,
                                           com.sshtools.j2ssh.transport.kex.KeyExchangeException
DOCUMENT ME!

Parameters:
kex - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!
com.sshtools.j2ssh.transport.kex.KeyExchangeException - DOCUMENT ME!

getKexAlgorithm

protected String getKexAlgorithm()
                          throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

beginKeyExchange

protected void beginKeyExchange()
                         throws IOException,
                                com.sshtools.j2ssh.transport.kex.KeyExchangeException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!
com.sshtools.j2ssh.transport.kex.KeyExchangeException - DOCUMENT ME!

createLocalKexInit

protected com.sshtools.j2ssh.transport.SshMsgKexInit createLocalKexInit()
                                                                 throws IOException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

onCorruptMac

protected void onCorruptMac()
DOCUMENT ME!


onMessageReceived

protected abstract void onMessageReceived(com.sshtools.j2ssh.transport.SshMessage msg)
                                   throws IOException
DOCUMENT ME!

Parameters:
msg - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

sendDisconnect

protected void sendDisconnect(int reason,
                              String description)
DOCUMENT ME!

Parameters:
reason - DOCUMENT ME!
description - DOCUMENT ME!

sendDisconnect

protected void sendDisconnect(int reason,
                              String description,
                              IOException error)
DOCUMENT ME!

Parameters:
reason - DOCUMENT ME!
description - DOCUMENT ME!
error - DOCUMENT ME!

sendKeyExchangeInit

protected void sendKeyExchangeInit()
                            throws IOException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!

sendNewKeys

protected void sendNewKeys()
                    throws IOException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!

setupNewKeys

protected abstract void setupNewKeys(byte[] encryptCSKey,
                                     byte[] encryptCSIV,
                                     byte[] encryptSCKey,
                                     byte[] encryptSCIV,
                                     byte[] macCSKey,
                                     byte[] macSCKey)
                              throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException,
                                     com.sshtools.j2ssh.transport.AlgorithmOperationException,
                                     com.sshtools.j2ssh.transport.AlgorithmNotSupportedException,
                                     com.sshtools.j2ssh.transport.AlgorithmInitializationException
DOCUMENT ME!

Parameters:
encryptCSKey - DOCUMENT ME!
encryptCSIV - DOCUMENT ME!
encryptSCKey - DOCUMENT ME!
encryptSCIV - DOCUMENT ME!
macCSKey - DOCUMENT ME!
macSCKey - DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!
AlgorithmOperationException - DOCUMENT ME!
AlgorithmNotSupportedException - DOCUMENT ME!
AlgorithmInitializationException - DOCUMENT ME!

completeKeyExchange

protected void completeKeyExchange()
                            throws IOException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!
TransportProtocolException - DOCUMENT ME!

getEventHandlers

protected List getEventHandlers()
DOCUMENT ME!

Returns:
DOCUMENT ME!

determineAlgorithm

protected String determineAlgorithm(List clientAlgorithms,
                                    List serverAlgorithms)
                             throws com.sshtools.j2ssh.transport.AlgorithmNotAgreedException
DOCUMENT ME!

Parameters:
clientAlgorithms - DOCUMENT ME!
serverAlgorithms - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
AlgorithmNotAgreedException - DOCUMENT ME!

startBinaryPacketProtocol

protected void startBinaryPacketProtocol()
                                  throws IOException
DOCUMENT ME!

Throws:
IOException - DOCUMENT ME!

stop

protected final void stop()
DOCUMENT ME!


readMessage

public com.sshtools.j2ssh.transport.SshMessage readMessage(int[] filter)
                                                    throws IOException
DOCUMENT ME!

Specified by:
readMessage in interface com.sshtools.j2ssh.transport.TransportProtocol
Parameters:
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

processMessages

protected com.sshtools.j2ssh.transport.SshMessage processMessages()
                                                           throws IOException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

addMessageStore

public void addMessageStore(com.sshtools.j2ssh.transport.SshMessageStore store)
                     throws com.sshtools.j2ssh.transport.MessageAlreadyRegisteredException
DOCUMENT ME!

Specified by:
addMessageStore in interface com.sshtools.j2ssh.transport.TransportProtocol
Parameters:
store - DOCUMENT ME!
Throws:
MessageAlreadyRegisteredException - DOCUMENT ME!

removeMessageStore

public void removeMessageStore(com.sshtools.j2ssh.transport.SshMessageStore ms)
DOCUMENT ME!

Parameters:
ms - DOCUMENT ME!