com.sshtools.j2ssh.transport

Class TransportProtocolCommon

Implemented Interfaces:
Runnable, TransportProtocol
Known Direct Subclasses:
TransportProtocolClient, TransportProtocolServer

public abstract class TransportProtocolCommon
extends java.lang.Object
implements TransportProtocol, Runnable

Version:
$Revision: 1.2 $
Author:
$author$

Field Summary

static int
EOL_CRLF
static int
EOL_LF
static String
PROTOCOL_VERSION
static String
SOFTWARE_VERSION_COMMENTS
protected TransportProtocolAlgorithmSync
algorithmsIn
protected TransportProtocolAlgorithmSync
algorithmsOut
protected String
clientIdent
protected SshMsgKexInit
clientKexInit
protected Boolean
completeOnNewKeys
protected byte[]
hostKey
protected HostKeyVerification
hosts
protected BigInteger
k
protected Map
kexs
protected static Log
log
protected SshMessageStore
messageStore
protected SshConnectionProperties
properties
protected String
serverIdent
protected SshMsgKexInit
serverKexInit
protected byte[]
sessionIdentifier
protected byte[]
signature
protected com.sshtools.j2ssh.transport.TransportProtocolInputStream
sshIn
protected com.sshtools.j2ssh.transport.TransportProtocolOutputStream
sshOut
protected TransportProtocolState
state

Constructor Summary

TransportProtocolCommon()
Creates a new TransportProtocolCommon object.

Method Summary

void
addEventHandler(TransportProtocolEventHandler eventHandler)
void
addMessageStore(SshMessageStore store)
protected void
beginKeyExchange()
protected void
completeKeyExchange()
protected SshMsgKexInit
createLocalKexInit()
protected String
determineAlgorithm(List clientAlgorithms, List serverAlgorithms)
void
disconnect(String description)
int
getConnectionId()
protected abstract String
getDecryptionAlgorithm()
protected abstract String
getEncryptionAlgorithm()
protected List
getEventHandlers()
long
getIncomingByteCount()
protected abstract String
getInputStreamCompAlgortihm()
protected abstract String
getInputStreamMacAlgorithm()
protected String
getKexAlgorithm()
abstract String
getLocalId()
protected abstract SshMsgKexInit
getLocalKexInit()
long
getOutgoingByteCount()
protected abstract String
getOutputStreamCompAlgorithm()
protected abstract String
getOutputStreamMacAlgorithm()
SshConnectionProperties
getProperties()
int
getRemoteEOL()
abstract String
getRemoteId()
protected abstract SshMsgKexInit
getRemoteKexInit()
byte[]
getSessionIdentifier()
TransportProtocolState
getState()
String
getUnderlyingProviderDetail()
boolean
isConnected()
protected void
onCorruptMac()
protected abstract void
onDisconnect()
protected abstract void
onMessageReceived(SshMessage msg)
protected abstract void
onStartTransportProtocol()
protected abstract void
performKeyExchange(SshKeyExchange kex)
protected SshMessage
processMessages()
SshMessage
readMessage(int[] filter)
abstract void
registerTransportMessages()
void
removeMessageStore(SshMessageStore ms)
void
run()
protected void
sendDisconnect(int reason, String description)
protected void
sendDisconnect(int reason, String description, IOException error)
protected void
sendKeyExchangeInit()
void
sendMessage(SshMessage msg, Object sender)
protected void
sendNewKeys()
void
setKexTimeout(long seconds)
void
setKexTransferLimit(long kilobytes)
protected abstract void
setLocalIdent()
protected abstract void
setLocalKexInit(SshMsgKexInit msg)
protected abstract void
setRemoteIdent(String ident)
protected abstract void
setRemoteKexInit(SshMsgKexInit msg)
void
setSendIgnore(boolean sendIgnore)
protected abstract void
setupNewKeys(byte[] encryptCSKey, byte[] encryptCSIV, byte[] encryptSCKey, byte[] encryptSCIV, byte[] macCSKey, byte[] macSCKey)
protected void
startBinaryPacketProtocol()
void
startTransportProtocol(TransportProvider provider, SshConnectionProperties properties)
protected void
stop()
void
unregisterMessage(Integer messageId, SshMessageStore store)

Field Details

EOL_CRLF

public static final int EOL_CRLF
Field Value:
1

EOL_LF

public static final int EOL_LF
Field Value:
2

PROTOCOL_VERSION

public static final String PROTOCOL_VERSION

SOFTWARE_VERSION_COMMENTS

public static String SOFTWARE_VERSION_COMMENTS

algorithmsIn

protected TransportProtocolAlgorithmSync algorithmsIn

algorithmsOut

protected TransportProtocolAlgorithmSync algorithmsOut

clientIdent

protected String clientIdent

clientKexInit

protected SshMsgKexInit clientKexInit

completeOnNewKeys

protected Boolean completeOnNewKeys

hostKey

protected byte[] hostKey

hosts

protected HostKeyVerification hosts

k

protected BigInteger k

kexs

protected Map kexs

log

protected static Log log

messageStore

protected SshMessageStore messageStore

properties

protected SshConnectionProperties properties

serverIdent

protected String serverIdent

serverKexInit

protected SshMsgKexInit serverKexInit

sessionIdentifier

protected byte[] sessionIdentifier

signature

protected byte[] signature

sshIn

protected com.sshtools.j2ssh.transport.TransportProtocolInputStream sshIn

sshOut

protected com.sshtools.j2ssh.transport.TransportProtocolOutputStream sshOut

state

protected TransportProtocolState state

Constructor Details

TransportProtocolCommon

public TransportProtocolCommon()
Creates a new TransportProtocolCommon object.

Method Details

addEventHandler

public void addEventHandler(TransportProtocolEventHandler eventHandler)
Parameters:
eventHandler -

addMessageStore

public void addMessageStore(SshMessageStore store)
            throws MessageAlreadyRegisteredException
Specified by:
addMessageStore in interface TransportProtocol
Parameters:
store -

beginKeyExchange

protected void beginKeyExchange()
            throws IOException,
                   KeyExchangeException

completeKeyExchange

protected void completeKeyExchange()
            throws IOException

createLocalKexInit

protected SshMsgKexInit createLocalKexInit()
            throws IOException
Returns:

determineAlgorithm

protected String determineAlgorithm(List clientAlgorithms,
                                    List serverAlgorithms)
            throws AlgorithmNotAgreedException
Parameters:
clientAlgorithms -
serverAlgorithms -
Returns:

disconnect

public void disconnect(String description)
Specified by:
disconnect in interface TransportProtocol
Parameters:
description -

getConnectionId

public int getConnectionId()
Specified by:
getConnectionId in interface TransportProtocol
Returns:

getDecryptionAlgorithm

protected abstract String getDecryptionAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getEncryptionAlgorithm

protected abstract String getEncryptionAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getEventHandlers

protected List getEventHandlers()
Returns:

getIncomingByteCount

public long getIncomingByteCount()
Returns:

getInputStreamCompAlgortihm

protected abstract String getInputStreamCompAlgortihm()
            throws AlgorithmNotAgreedException
Returns:

getInputStreamMacAlgorithm

protected abstract String getInputStreamMacAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getKexAlgorithm

protected String getKexAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getLocalId

public abstract String getLocalId()
Returns:

getLocalKexInit

protected abstract SshMsgKexInit getLocalKexInit()
Returns:

getOutgoingByteCount

public long getOutgoingByteCount()

getOutputStreamCompAlgorithm

protected abstract String getOutputStreamCompAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getOutputStreamMacAlgorithm

protected abstract String getOutputStreamMacAlgorithm()
            throws AlgorithmNotAgreedException
Returns:

getProperties

public SshConnectionProperties getProperties()
Returns:

getRemoteEOL

public int getRemoteEOL()
Returns:

getRemoteId

public abstract String getRemoteId()
Returns:

getRemoteKexInit

protected abstract SshMsgKexInit getRemoteKexInit()
Returns:

getSessionIdentifier

public byte[] getSessionIdentifier()
Specified by:
getSessionIdentifier in interface TransportProtocol
Returns:

getState

public TransportProtocolState getState()
Specified by:
getState in interface TransportProtocol
Returns:

getUnderlyingProviderDetail

public String getUnderlyingProviderDetail()
Specified by:
getUnderlyingProviderDetail in interface TransportProtocol
Returns:

isConnected

public boolean isConnected()
Specified by:
isConnected in interface TransportProtocol

onCorruptMac

protected void onCorruptMac()

onDisconnect

protected abstract void onDisconnect()

onMessageReceived

protected abstract void onMessageReceived(SshMessage msg)
            throws IOException
Parameters:
msg -

onStartTransportProtocol

protected abstract void onStartTransportProtocol()
            throws IOException

performKeyExchange

protected abstract void performKeyExchange(SshKeyExchange kex)
            throws IOException,
                   KeyExchangeException
Parameters:
kex -

processMessages

protected SshMessage processMessages()
            throws IOException
Returns:

readMessage

public SshMessage readMessage(int[] filter)
            throws IOException
Specified by:
readMessage in interface TransportProtocol
Parameters:
filter -
Returns:

registerTransportMessages

public abstract void registerTransportMessages()
            throws MessageAlreadyRegisteredException

removeMessageStore

public void removeMessageStore(SshMessageStore ms)
Parameters:
ms -

run

public void run()

sendDisconnect

protected void sendDisconnect(int reason,
                              String description)
Parameters:
reason -
description -

sendDisconnect

protected void sendDisconnect(int reason,
                              String description,
                              IOException error)
Parameters:
reason -
description -
error -

sendKeyExchangeInit

protected void sendKeyExchangeInit()
            throws IOException

sendMessage

public void sendMessage(SshMessage msg,
                        Object sender)
            throws IOException
Specified by:
sendMessage in interface TransportProtocol
Parameters:
msg -
sender -

sendNewKeys

protected void sendNewKeys()
            throws IOException

setKexTimeout

public void setKexTimeout(long seconds)
            throws TransportProtocolException
Parameters:
seconds -

setKexTransferLimit

public void setKexTransferLimit(long kilobytes)
            throws TransportProtocolException
Parameters:
kilobytes -

setLocalIdent

protected abstract void setLocalIdent()

setLocalKexInit

protected abstract void setLocalKexInit(SshMsgKexInit msg)
Parameters:
msg -

setRemoteIdent

protected abstract void setRemoteIdent(String ident)
Parameters:
ident -

setRemoteKexInit

protected abstract void setRemoteKexInit(SshMsgKexInit msg)
Parameters:
msg -

setSendIgnore

public void setSendIgnore(boolean sendIgnore)
Parameters:
sendIgnore -

setupNewKeys

protected abstract void setupNewKeys(byte[] encryptCSKey,
                                     byte[] encryptCSIV,
                                     byte[] encryptSCKey,
                                     byte[] encryptSCIV,
                                     byte[] macCSKey,
                                     byte[] macSCKey)
            throws AlgorithmNotAgreedException,
                   AlgorithmOperationException,
                   AlgorithmNotSupportedException,
                   AlgorithmInitializationException
Parameters:
encryptCSKey -
encryptCSIV -
encryptSCKey -
encryptSCIV -
macCSKey -
macSCKey -

startBinaryPacketProtocol

protected void startBinaryPacketProtocol()
            throws IOException

startTransportProtocol

public void startTransportProtocol(TransportProvider provider,
                                   SshConnectionProperties properties)
            throws IOException
Parameters:
provider -
properties -

stop

protected final void stop()

unregisterMessage

public void unregisterMessage(Integer messageId,
                              SshMessageStore store)
            throws MessageNotRegisteredException
Parameters:
messageId -
store -

Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.