Package com.sshtools.j2ssh.transport
Class TransportProtocolCommon
java.lang.Object
com.sshtools.j2ssh.transport.TransportProtocolCommon
- All Implemented Interfaces:
TransportProtocol
,Runnable
- Direct Known Subclasses:
TransportProtocolClient
,TransportProtocolServer
- Version:
- $Revision: 1.2 $
- Author:
- $author$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TransportProtocolAlgorithmSync
protected TransportProtocolAlgorithmSync
protected String
protected SshMsgKexInit
protected Boolean
static final int
static final int
protected byte[]
protected HostKeyVerification
protected BigInteger
protected Map
protected static org.apache.commons.logging.Log
protected SshMessageStore
protected SshConnectionProperties
static final String
protected String
protected SshMsgKexInit
protected byte[]
protected byte[]
static String
protected com.sshtools.j2ssh.transport.TransportProtocolInputStream
protected com.sshtools.j2ssh.transport.TransportProtocolOutputStream
protected TransportProtocolState
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEventHandler
(TransportProtocolEventHandler eventHandler) void
addMessageStore
(SshMessageStore store) protected void
protected void
protected SshMsgKexInit
protected String
determineAlgorithm
(List clientAlgorithms, List serverAlgorithms) void
disconnect
(String description) int
protected abstract String
protected abstract String
protected List
long
protected abstract String
protected abstract String
protected String
abstract String
protected abstract SshMsgKexInit
long
protected abstract String
protected abstract String
int
abstract String
protected abstract SshMsgKexInit
byte[]
getState()
boolean
protected void
protected abstract void
protected abstract void
protected abstract void
protected abstract void
protected SshMessage
readMessage
(int[] filter) abstract void
void
void
run()
protected void
sendDisconnect
(int reason, String description) protected void
sendDisconnect
(int reason, String description, IOException error) protected void
void
sendMessage
(SshMessage msg, Object sender) protected void
void
setKexTimeout
(long seconds) void
setKexTransferLimit
(long kilobytes) protected abstract void
protected abstract void
protected abstract void
setRemoteIdent
(String ident) protected abstract void
void
setSendIgnore
(boolean sendIgnore) protected abstract void
setupNewKeys
(byte[] encryptCSKey, byte[] encryptCSIV, byte[] encryptSCKey, byte[] encryptSCIV, byte[] macCSKey, byte[] macSCKey) protected void
void
startTransportProtocol
(TransportProvider provider, SshConnectionProperties properties) protected final void
stop()
void
unregisterMessage
(Integer messageId, SshMessageStore store)
-
Field Details
-
log
protected static org.apache.commons.logging.Log log -
EOL_CRLF
public static final int EOL_CRLF- See Also:
-
EOL_LF
public static final int EOL_LF- See Also:
-
PROTOCOL_VERSION
- See Also:
-
SOFTWARE_VERSION_COMMENTS
-
k
-
completeOnNewKeys
-
hosts
-
kexs
-
properties
-
messageStore
-
clientKexInit
-
serverKexInit
-
clientIdent
-
serverIdent
-
algorithmsIn
-
algorithmsOut
-
state
-
sessionIdentifier
protected byte[] sessionIdentifier -
hostKey
protected byte[] hostKey -
signature
protected byte[] signature -
sshIn
protected com.sshtools.j2ssh.transport.TransportProtocolInputStream sshIn -
sshOut
protected com.sshtools.j2ssh.transport.TransportProtocolOutputStream sshOut
-
-
Constructor Details
-
TransportProtocolCommon
public TransportProtocolCommon()Creates a new TransportProtocolCommon object.
-
-
Method Details
-
getConnectionId
public int getConnectionId()- Specified by:
getConnectionId
in interfaceTransportProtocol
- Returns:
-
getRemoteEOL
public int getRemoteEOL()- Returns:
-
getState
- Specified by:
getState
in interfaceTransportProtocol
- Returns:
-
getProperties
- Returns:
-
onDisconnect
protected abstract void onDisconnect() -
disconnect
- Specified by:
disconnect
in interfaceTransportProtocol
- Parameters:
description
-
-
setSendIgnore
public void setSendIgnore(boolean sendIgnore) - Parameters:
sendIgnore
-
-
setKexTimeout
- Parameters:
seconds
-- Throws:
TransportProtocolException
-
setKexTransferLimit
- Parameters:
kilobytes
-- Throws:
TransportProtocolException
-
getOutgoingByteCount
public long getOutgoingByteCount() -
getIncomingByteCount
public long getIncomingByteCount()- Returns:
-
addEventHandler
- Parameters:
eventHandler
-
-
registerTransportMessages
-
getSessionIdentifier
public byte[] getSessionIdentifier()- Specified by:
getSessionIdentifier
in interfaceTransportProtocol
- Returns:
-
run
public void run() -
sendMessage
- Specified by:
sendMessage
in interfaceTransportProtocol
- Parameters:
msg
-sender
-- Throws:
IOException
TransportProtocolException
-
onStartTransportProtocol
- Throws:
IOException
-
startTransportProtocol
public void startTransportProtocol(TransportProvider provider, SshConnectionProperties properties) throws IOException - Parameters:
provider
-properties
-- Throws:
IOException
-
getUnderlyingProviderDetail
- Specified by:
getUnderlyingProviderDetail
in interfaceTransportProtocol
- Returns:
-
unregisterMessage
public void unregisterMessage(Integer messageId, SshMessageStore store) throws MessageNotRegisteredException - Parameters:
messageId
-store
-- Throws:
MessageNotRegisteredException
-
getDecryptionAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
getEncryptionAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
getInputStreamCompAlgortihm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
getInputStreamMacAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
setLocalIdent
protected abstract void setLocalIdent() -
getLocalId
- Returns:
-
setLocalKexInit
- Parameters:
msg
-
-
getLocalKexInit
- Returns:
-
getOutputStreamCompAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
getOutputStreamMacAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
setRemoteIdent
- Parameters:
ident
-
-
getRemoteId
- Returns:
-
setRemoteKexInit
- Parameters:
msg
-
-
getRemoteKexInit
- Returns:
-
performKeyExchange
protected abstract void performKeyExchange(SshKeyExchange kex) throws IOException, KeyExchangeException - Parameters:
kex
-- Throws:
IOException
KeyExchangeException
-
getKexAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceTransportProtocol
-
beginKeyExchange
- Throws:
IOException
KeyExchangeException
-
createLocalKexInit
- Returns:
- Throws:
IOException
-
onCorruptMac
protected void onCorruptMac() -
onMessageReceived
- Parameters:
msg
-- Throws:
IOException
-
sendDisconnect
- Parameters:
reason
-description
-
-
sendDisconnect
- Parameters:
reason
-description
-error
-
-
sendKeyExchangeInit
- Throws:
IOException
-
sendNewKeys
- Throws:
IOException
-
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
-- Throws:
AlgorithmNotAgreedException
AlgorithmOperationException
AlgorithmNotSupportedException
AlgorithmInitializationException
-
completeKeyExchange
-
getEventHandlers
- Returns:
-
determineAlgorithm
protected String determineAlgorithm(List clientAlgorithms, List serverAlgorithms) throws AlgorithmNotAgreedException - Parameters:
clientAlgorithms
-serverAlgorithms
-- Returns:
- Throws:
AlgorithmNotAgreedException
-
startBinaryPacketProtocol
- Throws:
IOException
-
stop
protected final void stop() -
readMessage
- Specified by:
readMessage
in interfaceTransportProtocol
- Parameters:
filter
-- Returns:
- Throws:
IOException
-
processMessages
- Returns:
- Throws:
IOException
-
addMessageStore
- Specified by:
addMessageStore
in interfaceTransportProtocol
- Parameters:
store
-- Throws:
MessageAlreadyRegisteredException
-
removeMessageStore
- Parameters:
ms
-
-