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 TransportProtocolAlgorithmSyncprotected TransportProtocolAlgorithmSyncprotected Stringprotected SshMsgKexInitprotected Booleanstatic final intstatic final intprotected byte[]protected HostKeyVerificationprotected BigIntegerprotected Mapprotected static org.apache.commons.logging.Logprotected SshMessageStoreprotected SshConnectionPropertiesstatic final Stringprotected Stringprotected SshMsgKexInitprotected byte[]protected byte[]static Stringprotected com.sshtools.j2ssh.transport.TransportProtocolInputStreamprotected com.sshtools.j2ssh.transport.TransportProtocolOutputStreamprotected TransportProtocolState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventHandler(TransportProtocolEventHandler eventHandler) voidaddMessageStore(SshMessageStore store) protected voidprotected voidprotected SshMsgKexInitprotected StringdetermineAlgorithm(List clientAlgorithms, List serverAlgorithms) voiddisconnect(String description) intprotected abstract Stringprotected abstract Stringprotected Listlongprotected abstract Stringprotected abstract Stringprotected Stringabstract Stringprotected abstract SshMsgKexInitlongprotected abstract Stringprotected abstract Stringintabstract Stringprotected abstract SshMsgKexInitbyte[]getState()booleanprotected voidprotected abstract voidprotected abstract voidprotected abstract voidprotected abstract voidprotected SshMessagereadMessage(int[] filter) abstract voidvoidvoidrun()protected voidsendDisconnect(int reason, String description) protected voidsendDisconnect(int reason, String description, IOException error) protected voidvoidsendMessage(SshMessage msg, Object sender) protected voidvoidsetKexTimeout(long seconds) voidsetKexTransferLimit(long kilobytes) protected abstract voidprotected abstract voidprotected abstract voidsetRemoteIdent(String ident) protected abstract voidvoidsetSendIgnore(boolean sendIgnore) protected abstract voidsetupNewKeys(byte[] encryptCSKey, byte[] encryptCSIV, byte[] encryptSCKey, byte[] encryptSCIV, byte[] macCSKey, byte[] macSCKey) protected voidvoidstartTransportProtocol(TransportProvider provider, SshConnectionProperties properties) protected final voidstop()voidunregisterMessage(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:
getConnectionIdin interfaceTransportProtocol- Returns:
-
getRemoteEOL
public int getRemoteEOL()- Returns:
-
getState
- Specified by:
getStatein interfaceTransportProtocol- Returns:
-
getProperties
- Returns:
-
onDisconnect
protected abstract void onDisconnect() -
disconnect
- Specified by:
disconnectin 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:
getSessionIdentifierin interfaceTransportProtocol- Returns:
-
run
public void run() -
sendMessage
- Specified by:
sendMessagein interfaceTransportProtocol- Parameters:
msg-sender-- Throws:
IOExceptionTransportProtocolException
-
onStartTransportProtocol
- Throws:
IOException
-
startTransportProtocol
public void startTransportProtocol(TransportProvider provider, SshConnectionProperties properties) throws IOException - Parameters:
provider-properties-- Throws:
IOException
-
getUnderlyingProviderDetail
- Specified by:
getUnderlyingProviderDetailin 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:
IOExceptionKeyExchangeException
-
getKexAlgorithm
- Returns:
- Throws:
AlgorithmNotAgreedException
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceTransportProtocol
-
beginKeyExchange
- Throws:
IOExceptionKeyExchangeException
-
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:
AlgorithmNotAgreedExceptionAlgorithmOperationExceptionAlgorithmNotSupportedExceptionAlgorithmInitializationException
-
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:
readMessagein interfaceTransportProtocol- Parameters:
filter-- Returns:
- Throws:
IOException
-
processMessages
- Returns:
- Throws:
IOException
-
addMessageStore
- Specified by:
addMessageStorein interfaceTransportProtocol- Parameters:
store-- Throws:
MessageAlreadyRegisteredException
-
removeMessageStore
- Parameters:
ms-
-