com.sshtools.j2ssh.transport
Class TransportProtocolClient

java.lang.Object
  |
  +--com.sshtools.j2ssh.transport.TransportProtocolCommon
        |
        +--com.sshtools.j2ssh.transport.TransportProtocolClient
All Implemented Interfaces:
java.lang.Runnable, TransportProtocol

public class TransportProtocolClient
extends TransportProtocolCommon

Implements the client side of the SSH transport protocol. Specifically this class initiates client side key exchange operations and provides a mechanism to request SSH services from the remote server.

Version:
1.0
Author:
Lee David Painter ( lee@sshtools.com )

Field Summary
 
Fields inherited from class com.sshtools.j2ssh.transport.TransportProtocolCommon
clientIdent, clientKexInit, completeOnNewKeys, exchangeHash, hostKey, hosts, k, kex, log, messageStore, pk, properties, PROTOCOL_VERSION, serverIdent, serverKexInit, signature, SOFTWARE_VERSION_COMMENTS
 
Constructor Summary
TransportProtocolClient(java.net.Socket socket, SshConnectionProperties properties, HostKeyVerification hosts)
          Constructor for the SshTransportProtocolClient object
 
Method Summary
protected  java.lang.String getDecryptionAlgorithm()
          Returns the decryption algorithm to be used after key exchange.
protected  java.lang.String getEncryptionAlgorithm()
          Returns the encryption algorithm to be used after key exchange.
protected  java.lang.String getInputStreamCompAlgortihm()
          Returns the input stream compression algorithm to be used after key exchange.
protected  java.lang.String getInputStreamMacAlgorithm()
          Returns the input stream MAC algorithm to be used after key exchange.
protected  java.lang.String getLocalIdent()
          Returns the local protocol identification string.
protected  com.sshtools.j2ssh.transport.SshMsgKexInit getLocalKexInit()
          Gets the local sides kex init message.
protected  java.lang.String getOutputStreamCompAlgorithm()
          Returns the output stream compression algorithm to be used after key exchange.
protected  java.lang.String getOutputStreamMacAlgorithm()
          Returns the output stream MAC algorithm to be used after key exchange.
protected  java.lang.String getRemoteIdent()
          Returns the remote computers protocol identification string.
protected  com.sshtools.j2ssh.transport.SshMsgKexInit getRemoteKexInit()
          Gets the remote computers kex init message
protected  boolean onBeginKeyExchange(SshKeyExchange kex)
          Called by the abstract super class when key exchange begins.
 void onMessageReceived(SshMessage msg)
          Called by the framework when a registered message is received.
protected  void onMsgServiceAccept(com.sshtools.j2ssh.transport.SshMsgServiceAccept msg)
          Handles the SSH_MSG_SERVICE_ACCEPT message
 Service requestService(java.lang.String serviceName)
          Requests that the remote computer start the specified service.
protected  void setLocalIdent()
          Sets the local sides identification string.
protected  void setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
          Called by the abstract super class to set the relevant kex init member variable according to the subclasses operation (client or server)
protected  void setRemoteIdent(java.lang.String ident)
          Sets the remote sides identification string.
protected  void setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
          Called by the abstract super class to set the remote sides kex init message.
protected  boolean verifyHostKey()
          Verifies the server host key using the public key algorithm negotiated during key exchange.
 
Methods inherited from class com.sshtools.j2ssh.transport.TransportProtocolCommon
beginKeyExchange, completeKeyExchange, determineAlgorithm, disconnect, getKexAlgorithm, getState, onChildThreadException, onCorruptMac, onMessageData, registerMessage, removeServiceThread, reportDisconnect, reportException, run, sendDisconnect, sendKeyExchangeInit, sendMessage, sendNewKeys, setServiceThread, stop, unregisterMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransportProtocolClient

public TransportProtocolClient(java.net.Socket socket,
                               SshConnectionProperties properties,
                               HostKeyVerification hosts)
                        throws TransportProtocolException
Constructor for the SshTransportProtocolClient object

Parameters:
socket - The connected socket.
properties - The SSH connection properties for the current connection
hosts - Description of the Parameter
Throws:
TransportProtocolException - Description of the Exception
Method Detail

setLocalIdent

protected void setLocalIdent()
Sets the local sides identification string. This is sent initially to determine the protocol version. As the common layer cannot determine whether it is running as a client or server, this method allows the subclasses to correctly set the relevant protected member variable.

Specified by:
setLocalIdent in class TransportProtocolCommon

setRemoteIdent

protected void setRemoteIdent(java.lang.String ident)
Sets the remote sides identification string.

Specified by:
setRemoteIdent in class TransportProtocolCommon
Parameters:
ident - The protocol version string received

getLocalIdent

protected java.lang.String getLocalIdent()
Returns the local protocol identification string. We return the relevant protected member variable for the subclass implementation.

Specified by:
getLocalIdent in class TransportProtocolCommon
Returns:
The local identification string

getRemoteIdent

protected java.lang.String getRemoteIdent()
Returns the remote computers protocol identification string.

Specified by:
getRemoteIdent in class TransportProtocolCommon
Returns:
The remote identificaiton string

setLocalKexInit

protected void setLocalKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
Called by the abstract super class to set the relevant kex init member variable according to the subclasses operation (client or server)

Specified by:
setLocalKexInit in class TransportProtocolCommon
Parameters:
msg - The kex init message sent by the local machine

setRemoteKexInit

protected void setRemoteKexInit(com.sshtools.j2ssh.transport.SshMsgKexInit msg)
Called by the abstract super class to set the remote sides kex init message.

Specified by:
setRemoteKexInit in class TransportProtocolCommon
Parameters:
msg - The kex init message received from the remote computer.

getLocalKexInit

protected com.sshtools.j2ssh.transport.SshMsgKexInit getLocalKexInit()
Gets the local sides kex init message.

Specified by:
getLocalKexInit in class TransportProtocolCommon
Returns:
The local sides kex init message

getRemoteKexInit

protected com.sshtools.j2ssh.transport.SshMsgKexInit getRemoteKexInit()
Gets the remote computers kex init message

Specified by:
getRemoteKexInit in class TransportProtocolCommon
Returns:
The remote computers kex init

getEncryptionAlgorithm

protected java.lang.String getEncryptionAlgorithm()
                                           throws AlgorithmNotAgreedException
Returns the encryption algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getEncryptionAlgorithm in class TransportProtocolCommon
Returns:
The algortihm name
Throws:
AlgorithmNotAgreedException - Thrown if an algorithm cannot be agreed

getDecryptionAlgorithm

protected java.lang.String getDecryptionAlgorithm()
                                           throws AlgorithmNotAgreedException
Returns the decryption algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getDecryptionAlgorithm in class TransportProtocolCommon
Returns:
The algorithm name.
Throws:
AlgorithmNotAgreedException - Thrown if the algorithm cannot be agreed.

getOutputStreamMacAlgorithm

protected java.lang.String getOutputStreamMacAlgorithm()
                                                throws AlgorithmNotAgreedException
Returns the output stream MAC algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getOutputStreamMacAlgorithm in class TransportProtocolCommon
Returns:
The algorithm name.
Throws:
AlgorithmNotAgreedException - Thrown if an algorithm cannot be agreed.

getInputStreamMacAlgorithm

protected java.lang.String getInputStreamMacAlgorithm()
                                               throws AlgorithmNotAgreedException
Returns the input stream MAC algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getInputStreamMacAlgorithm in class TransportProtocolCommon
Returns:
The algorithm name.
Throws:
AlgorithmNotAgreedException - Thrown if an algorithm cannot be agreed.

getOutputStreamCompAlgorithm

protected java.lang.String getOutputStreamCompAlgorithm()
                                                 throws AlgorithmNotAgreedException
Returns the output stream compression algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getOutputStreamCompAlgorithm in class TransportProtocolCommon
Returns:
The algorithm name.
Throws:
AlgorithmNotAgreedException - Thrown if an algorithm cannot be agreed.

getInputStreamCompAlgortihm

protected java.lang.String getInputStreamCompAlgortihm()
                                                throws AlgorithmNotAgreedException
Returns the input stream compression algorithm to be used after key exchange. This method evaluates the supported algorithms of both sides and determines the correct algorithm.

Specified by:
getInputStreamCompAlgortihm in class TransportProtocolCommon
Returns:
The algorithm name.
Throws:
AlgorithmNotAgreedException - Thrown if an algorithm cannot be agreed.

requestService

public Service requestService(java.lang.String serviceName)
                       throws TransportProtocolException,
                              ServiceOperationException
Requests that the remote computer start the specified service.

Parameters:
serviceName - The service name to start
Returns:
The service instance.
Throws:
TransportProtocolException - Thrown if a transport protocol exception occurs
ServiceOperationException - Thrown if the service does not initialize properly.

verifyHostKey

protected boolean verifyHostKey()
                         throws InvalidHostKeyException,
                                InvalidHostKeySignatureException,
                                AlgorithmNotAgreedException,
                                AlgorithmNotSupportedException,
                                InvalidHostFileException
Verifies the server host key using the public key algorithm negotiated during key exchange.

Returns:
The result of the verification
Throws:
InvalidHostKeyException - Description of the Exception
InvalidHostKeySignatureException - Description of the Exception
AlgorithmNotAgreedException - Description of the Exception
AlgorithmNotSupportedException - Description of the Exception
InvalidHostFileException - Description of the Exception

onBeginKeyExchange

protected boolean onBeginKeyExchange(SshKeyExchange kex)
                              throws TransportProtocolException
Called by the abstract super class when key exchange begins.

Specified by:
onBeginKeyExchange in class TransportProtocolCommon
Parameters:
kex - Description of the Parameter
Returns:
Description of the Return Value
Throws:
TransportProtocolException - Can be thrown to indicate a fatal error (not key exchange failure)

onMsgServiceAccept

protected void onMsgServiceAccept(com.sshtools.j2ssh.transport.SshMsgServiceAccept msg)
Handles the SSH_MSG_SERVICE_ACCEPT message

Parameters:
msg - The message received

onMessageReceived

public void onMessageReceived(SshMessage msg)
Called by the framework when a registered message is received.

Specified by:
onMessageReceived in class TransportProtocolCommon
Parameters:
msg - The message received.


Copyright © 2002 Sshtools.com. All Rights Reserved.