|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sshtools.j2ssh.transport.TransportProtocolCommon
The main transport protocol implementation. This abstract class provides the common functionality of both client and server implementations.
Field Summary | |
protected java.lang.String |
clientIdent
The identification string sent by the client |
protected com.sshtools.j2ssh.transport.SshMsgKexInit |
clientKexInit
The key exchange init message sent by the client |
protected java.lang.Boolean |
completeOnNewKeys
Indicates when either the remote or local side has completed key exchange |
protected byte[] |
exchangeHash
The exchange hash output from key exchange |
protected byte[] |
hostKey
The servers host key data |
protected HostKeyVerification |
hosts
Description of the Field |
protected java.math.BigInteger |
k
The secret value k produced during key exchange |
protected SshKeyExchange |
kex
The key exchange engine |
protected static Logger |
log
The log4j log object |
protected SshMessageStore |
messageStore
The transport layer's message store |
protected SshPublicKey |
pk
The public key object used in host key verification |
protected SshConnectionProperties |
properties
The connection properties for the current connection |
java.lang.String |
PROTOCOL_VERSION
The protocol version supported |
protected java.lang.String |
serverIdent
The identification string sent by the server |
protected com.sshtools.j2ssh.transport.SshMsgKexInit |
serverKexInit
The key exchange init message sent by the server |
protected byte[] |
signature
The servers signature supplied to verify the host key |
java.lang.String |
SOFTWARE_VERSION_COMMENTS
The software version comments that are sent during protocol negotiation |
Constructor Summary | |
TransportProtocolCommon(java.net.Socket socket,
SshConnectionProperties properties,
HostKeyVerification hosts)
Constructor for the SshTransportProtocol object |
Method Summary | |
protected void |
beginKeyExchange()
Sets the transport layer up for performing the key exchange, this is called when either a SSH_MSG_KEXINIT message is received or sent by either party |
protected void |
completeKeyExchange()
Completes key exchange by creating keys from the exchange hash and puts them into use |
protected java.lang.String |
determineAlgorithm(java.util.List clientAlgorithms,
java.util.List serverAlgorithms)
Helper method to determine the first algorithm that appears in the client list that is also supported by the server |
void |
disconnect(java.lang.String description)
Disconnects the connection by sending a disconnect message with the BY_APPLICAITON reason. |
protected abstract java.lang.String |
getDecryptionAlgorithm()
Abstract method to determine the correct decryption algorithm to use This is found by iterating through the clients supported algorithm and selecting the first supported decryption method that the server also supports. |
protected abstract java.lang.String |
getEncryptionAlgorithm()
Abstract method to determine the correct encryption algorithm to use This is found by iterating through the clients supported algorithm and selecting the first supported encryption method that the server also supports. |
protected abstract java.lang.String |
getInputStreamCompAlgortihm()
Abtract method for the client/server implmentations to determine the compression algorithm for the input stream. |
protected abstract java.lang.String |
getInputStreamMacAlgorithm()
Abtract method for the client/server implmentations to determine the message authentication algorithm for the input stream. |
protected java.lang.String |
getKexAlgorithm()
Determines the correct key exchange algorithm to use |
protected abstract java.lang.String |
getLocalIdent()
Abstract method to return the local identification string which is used in protocol negotiation and in computing the exchange hash. |
protected abstract com.sshtools.j2ssh.transport.SshMsgKexInit |
getLocalKexInit()
Abstract method to get the local kex init msg which is used in computing the exchange hash. |
protected abstract java.lang.String |
getOutputStreamCompAlgorithm()
Abtract method for the client/server implmentations to determine the compression algorithm for the output stream. |
protected abstract java.lang.String |
getOutputStreamMacAlgorithm()
Abtract method for the client/server implmentations to determine the message authentication algorithm for the output stream. |
protected abstract java.lang.String |
getRemoteIdent()
Abstract method to return the remote identification string which is used in protocol negotiation and in computing the exchange hash. |
protected abstract com.sshtools.j2ssh.transport.SshMsgKexInit |
getRemoteKexInit()
Abstract method to get the remote kex init msg which is used in computing the exchange hash. |
TransportProtocolState |
getState()
Gets the state attribute of the TransportProtocolCommon object |
protected abstract boolean |
onBeginKeyExchange(SshKeyExchange kex)
Abstract method called when key exchange has begun |
protected void |
onChildThreadException(java.lang.Exception e)
Called if an inputstream error occurs |
protected void |
onCorruptMac()
This is called when a corrupt Mac has been received on the input stream. |
protected void |
onMessageData(int messageId,
ByteArrayReader bar)
Called by the framework when a new message is received |
protected abstract void |
onMessageReceived(SshMessage msg)
Called by the framework when a new message is received. |
void |
registerMessage(java.lang.Integer messageId,
java.lang.Class implementor,
SshMessageStore store)
Implements the TransportProtocol interface method to allow external SSH implementations to receive message notificaitons. |
void |
removeServiceThread(Service service)
Removes thes service thread from the exception notification list. |
protected void |
reportDisconnect(java.lang.String reason)
Reports a disconnect to service threads. |
protected void |
reportException(java.lang.Exception e)
Reports an exception to service threads |
void |
run()
Main processing method for the TransportProtocolCommon object |
protected void |
sendDisconnect(int reason,
java.lang.String description)
Sends a disconnect message |
protected void |
sendKeyExchangeInit()
Sends the key exchange init message |
void |
sendMessage(SshMessage msg,
java.lang.Object sender)
Send an SSH message, if the state doen't allow it because of key exchange then the message is stored and sent as soon as the state changes |
protected void |
sendNewKeys()
Sends the SSH_MSG_NEWKEYS message to indicate that new keys are now in operation |
protected abstract void |
setLocalIdent()
Abstract method that requires a derived class to set value of the local identification string. |
protected abstract void |
setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
Abstract method to set the local kex init msg which is used in computing the exchange hash. |
protected abstract void |
setRemoteIdent(java.lang.String ident)
Abstract method that requires a derived class to set value of the remote identification string. |
protected abstract void |
setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
Abstract method to set the remote kex init msg which is used in computing the exchange hash. |
void |
setServiceThread(Service service)
Sets a service thread so that it receives notifications of exceptions. |
protected void |
stop()
Stops the transport layer |
void |
unregisterMessage(java.lang.Integer messageId,
SshMessageStore store)
Implements the TransportProtocol method to allow external SSH implementations to unregister a message. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected HostKeyVerification hosts
protected SshMessageStore messageStore
protected static Logger log
public final java.lang.String SOFTWARE_VERSION_COMMENTS
public final java.lang.String PROTOCOL_VERSION
protected java.lang.String serverIdent
protected java.lang.String clientIdent
protected com.sshtools.j2ssh.transport.SshMsgKexInit clientKexInit
protected com.sshtools.j2ssh.transport.SshMsgKexInit serverKexInit
protected java.lang.Boolean completeOnNewKeys
protected byte[] exchangeHash
protected byte[] hostKey
protected byte[] signature
protected SshPublicKey pk
protected java.math.BigInteger k
protected SshKeyExchange kex
protected SshConnectionProperties properties
Constructor Detail |
public TransportProtocolCommon(java.net.Socket socket, SshConnectionProperties properties, HostKeyVerification hosts) throws TransportProtocolException
socket
- A connected socket to the remote
hostproperties
- The connection properties of the
ssh connectionhosts
- Description of the Parameter
TransportProtocolException
- Description of the ExceptionMethod Detail |
protected abstract void setLocalIdent()
protected abstract void setRemoteIdent(java.lang.String ident)
ident
- The identifiaction string received from the remote hostprotected abstract java.lang.String getLocalIdent()
protected abstract java.lang.String getRemoteIdent()
protected abstract void setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
msg
- The local computers kex init messageprotected abstract void setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
msg
- The remote computers kex init messageprotected abstract com.sshtools.j2ssh.transport.SshMsgKexInit getLocalKexInit()
protected abstract com.sshtools.j2ssh.transport.SshMsgKexInit getRemoteKexInit()
protected abstract boolean onBeginKeyExchange(SshKeyExchange kex) throws TransportProtocolException
kex
- Description of the Parameter
TransportProtocolException
- Description of the Exceptionprotected java.lang.String getKexAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When no algorithm is agreed between
the two parties an exception is thrownprotected abstract java.lang.String getEncryptionAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownprotected abstract java.lang.String getDecryptionAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownprotected abstract java.lang.String getOutputStreamMacAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownprotected abstract java.lang.String getInputStreamMacAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownprotected abstract java.lang.String getOutputStreamCompAlgorithm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownprotected abstract java.lang.String getInputStreamCompAlgortihm() throws AlgorithmNotAgreedException
AlgorithmNotAgreedException
- When an algorithm cannot be
agreed an exception is thrownpublic TransportProtocolState getState()
public void run()
run
in interface java.lang.Runnable
protected final void stop()
protected void beginKeyExchange() throws TransportProtocolException
TransportProtocolException
- Description of the Exceptionprotected void sendNewKeys() throws TransportProtocolException
TransportProtocolException
- Description of the Exceptionprotected void completeKeyExchange() throws TransportProtocolException
TransportProtocolException
- Description of the Exceptionprotected java.lang.String determineAlgorithm(java.util.List clientAlgorithms, java.util.List serverAlgorithms) throws AlgorithmNotAgreedException
clientAlgorithms
- The list of client algorithmsserverAlgorithms
- The list of server algorithms
AlgorithmNotAgreedException
- Thrown if the algorithm cannot be
agreedpublic void sendMessage(SshMessage msg, java.lang.Object sender) throws TransportProtocolException
sendMessage
in interface TransportProtocol
msg
- The SshMessage to sendsender
- Description of the Parameter
TransportProtocolException
- Description of the Exceptionprotected void onCorruptMac()
public void registerMessage(java.lang.Integer messageId, java.lang.Class implementor, SshMessageStore store) throws MessageAlreadyRegisteredException
registerMessage
in interface TransportProtocol
messageId
- The messageId of the
registered messageimplementor
- The class that implements
the messagestore
- The message store to
receive notificaiton
MessageAlreadyRegisteredException
- Thrown if the message
cannot be registered.public void unregisterMessage(java.lang.Integer messageId, SshMessageStore store) throws MessageNotRegisteredException
unregisterMessage
in interface TransportProtocol
messageId
- The message id of the messagestore
- The message store receiving the
notifications.
MessageNotRegisteredException
- Thrown if the message is not
registered.protected void sendDisconnect(int reason, java.lang.String description)
reason
- The reason code.description
- The readable reason description.public void disconnect(java.lang.String description)
disconnect
in interface TransportProtocol
description
- The description of the reasonprotected void onMessageData(int messageId, ByteArrayReader bar) throws InvalidMessageException, TransportProtocolException
messageId
- Description of the Parameterbar
- Description of the Parameter
InvalidMessageException
- Description of the Exception
TransportProtocolException
- Description of the Exceptionprotected abstract void onMessageReceived(SshMessage msg)
msg
- The message receviedprotected void sendKeyExchangeInit() throws TransportProtocolException
TransportProtocolException
- Description of the Exceptionprotected void onChildThreadException(java.lang.Exception e)
e
- Description of the Parameterpublic void setServiceThread(Service service)
Sets a service thread so that it receives notifications of exceptions.
setServiceThread
in interface TransportProtocol
service
- public void removeServiceThread(Service service)
Removes thes service thread from the exception notification list.
removeServiceThread
in interface TransportProtocol
service
- protected void reportException(java.lang.Exception e)
Reports an exception to service threads
e
- protected void reportDisconnect(java.lang.String reason)
Reports a disconnect to service threads.
reason
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |