public abstract class TransportProtocol<T extends SshContext> extends ExecutorOperationSupport<SshContext> implements ProtocolEngine, IdleStateListener, SshTransport<T>
| Modifier and Type | Field and Description |
|---|---|
protected Service |
activeService |
static int |
AUTH_CANCELLED_BY_USER
Disconnect reason: Authentication was cancelled
|
static int |
BY_APPLICATION
Disconnect reason: The application disconnected
|
static java.lang.String |
CHARSET_ENCODING
Character set encoding.
|
protected java.lang.String |
cipherCS |
protected java.lang.String |
cipherSC |
protected boolean |
completedFirstKeyExchange |
static int |
COMPRESSION_ERROR
Disconnect reason: A compression error occurred
|
protected java.lang.String |
compressionCS |
protected java.lang.String |
compressionSC |
protected Connection<T> |
con |
static int |
CONNECTED
Protocol state: The transport protocol is connected and services can be
started or may already be active.
|
static int |
CONNECTION_LOST
Disconnect reason: The connection was lost
|
static int |
DISCONNECTED
Protocol state: The transport protocol has disconnected.
|
protected java.util.Date |
disconnectStarted |
static int |
HOST_KEY_NOT_VERIFIABLE
Disconnect reason: The host key supplied could not be verified
|
static int |
HOST_NOT_ALLOWED
Disconnect reason: The host is not allowed
|
protected SshPublicKey |
hostKey |
static int |
ILLEGAL_USER_NAME
Disconnect reason: The user's name is illegal
|
static int |
KEY_EXCHANGE_FAILED
Disconnect reason: Key exchange failed
|
protected java.lang.String |
keyExchangeAlgorithm |
protected java.lang.String |
localIdentification |
protected byte[] |
localkex |
static java.lang.Object |
lock |
static int |
MAC_ERROR
Disconnect reason: An error occurred verifying the MAC
|
protected java.lang.String |
macCS |
protected java.lang.String |
macSC |
static int |
NEGOTIATING_PROTOCOL
Protocol state: Negotation of the protocol version
|
static int |
NO_MORE_AUTH_METHODS_AVAILABLE
Disconnect reason: No more authentication methods are available
|
static int |
PERFORMING_KEYEXCHANGE
Protocol state: The protocol is performing key exchange
|
static int |
PROTOCOL_ERROR
Disconnect reason: A protocol error occurred
|
static int |
PROTOCOL_VERSION_NOT_SUPPORTED
Disconnect reason: The protocol version is not supported
|
protected java.lang.String |
publicKey |
protected boolean |
receivedRemoteIdentification |
protected java.lang.StringBuffer |
remoteIdentification |
protected byte[] |
remotekex |
static int |
RESERVED
Disconnect reason: Reserved
|
protected boolean |
sentLocalIdentification |
static int |
SERVICE_NOT_AVAILABLE
Disconnect reason: The requested service is not available
|
protected byte[] |
sessionIdentifier |
protected SocketConnection |
socketConnection |
static int |
SSH_MSG_SERVICE_ACCEPT |
protected static int |
SSH_MSG_SERVICE_REQUEST |
protected T |
sshContext |
static int |
TOO_MANY_CONNECTIONS
Disconnect reason: Too many connections, try later
|
protected java.util.UUID |
uuid |
CALLBACKS, EVENTS, MESSAGES_INCOMING, MESSAGES_OUTGOING| Constructor and Description |
|---|
TransportProtocol(T sshContext,
ConnectRequestFuture connectFuture)
Create a default transport protocol instance in CLIENT_MODE.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(TransportProtocolListener listener) |
protected abstract boolean |
canConnect(SocketConnection connection) |
protected boolean |
canSendKeyExchangeInit() |
protected void |
completeKeyExchange(SshKeyExchange<T> keyExchange) |
void |
disconnect(int reason,
java.lang.String description)
Disconnect from the remote host.
|
protected abstract void |
disconnected() |
protected void |
generateNewKeysClientIn() |
protected void |
generateNewKeysClientOut() |
protected void |
generateNewKeysServerIn() |
protected void |
generateNewKeysServerOut() |
static byte[] |
getBytes(java.lang.String str,
java.lang.String charset) |
java.lang.String |
getCipherCS() |
java.lang.String |
getCipherSC() |
java.lang.String |
getCompressionCS() |
java.lang.String |
getCompressionSC() |
ConnectRequestFuture |
getConnectFuture() |
Connection<T> |
getConnection() |
protected abstract java.net.SocketAddress |
getConnectionAddress() |
T |
getContext() |
DisconnectRequestFuture |
getDisconnectFuture() |
ExecutorOperationSupport<?> |
getExecutor() |
SshPublicKey |
getHostKey() |
java.lang.String |
getHostKeyAlgorithm() |
java.lang.String |
getHostKeyInUse() |
java.lang.String |
getKeyExchangeAlgorithm() |
java.lang.String |
getKeyExchangeInUse() |
java.net.SocketAddress |
getLocalAddress()
Returns the local address to which the remote socket is connected.
|
java.lang.String |
getLocalIdentification() |
int |
getLocalPort()
Returns the local port to which the remote socket is connected.
|
java.lang.String |
getMacCS() |
java.lang.String |
getMacSC() |
int |
getQueueSizes() |
java.net.SocketAddress |
getRemoteAddress() |
java.lang.String[] |
getRemoteCiphersCS() |
java.lang.String[] |
getRemoteCiphersSC() |
java.lang.String[] |
getRemoteCompressionsCS() |
java.lang.String[] |
getRemoteCompressionsSC() |
java.lang.String |
getRemoteIdentification() |
java.lang.String[] |
getRemoteKeyExchanges() |
java.lang.String[] |
getRemoteMacsCS() |
java.lang.String[] |
getRemoteMacsSC() |
int |
getRemotePort()
Returns the remote port of the connected socket.
|
java.lang.String[] |
getRemotePublicKeys() |
java.security.SecureRandom |
getRND()
Gets the secure random number generator for this transport.
|
byte[] |
getSessionKey() |
SocketConnection |
getSocketConnection()
Get the
SocketConnection for this connection. |
T |
getSshContext() |
int |
getState() |
java.lang.String |
getUUID() |
boolean |
hasCompletedKeyExchange() |
boolean |
idle()
Called when the selector framework is idle.
|
protected abstract void |
initializeKeyExchange(SshKeyExchange<T> keyExchange,
boolean firstPacketFollows,
boolean useFirstPacket) |
boolean |
isConnected()
Determine if the protocol is still connected
|
boolean |
isSelectorThread() |
protected void |
keyExchangeInitialized() |
void |
kill() |
protected abstract void |
onConnected() |
protected abstract void |
onDisconnected() |
protected abstract void |
onKeyExchangeInit() |
protected abstract void |
onNewKeysReceived() |
protected abstract void |
onNewKeysSent() |
protected void |
onRemoteIdentificationReceived(java.lang.String remoteIdentification) |
void |
onSocketClose()
Disconnects everything internally
|
void |
onSocketConnect(SocketConnection connection)
The socket is connected and the protocol can now start.
|
boolean |
onSocketRead(java.nio.ByteBuffer incomingData)
Called when the socket channel is reported to be ready for reading.
|
SocketWriteCallback |
onSocketWrite(java.nio.ByteBuffer outgoingMessage)
Called when the socket channel is reported to be ready for writing.
|
void |
postMessage(SshMessage msg) |
void |
postMessage(SshMessage msg,
boolean kex) |
void |
processMessage(byte[] msg,
long sequenceNo)
Process a message.
|
protected abstract boolean |
processTransportMessage(int msgid,
byte[] msg) |
void |
registerIdleStateListener(IdleStateListener listener) |
void |
removeIdleStateListener(IdleStateListener listener) |
void |
resetIdleState(IdleStateListener listener) |
protected java.lang.String |
selectNegotiatedComponent(java.lang.String clientlist,
java.lang.String serverlist) |
void |
sendNewKeys() |
protected void |
transferState(TransportProtocol<? extends SshContext> transport) |
boolean |
wantsToWrite()
Determines whether the protocol wants to write to the socket.
|
addIncomingTask, addOutgoingTask, addTask, cleanupOperationsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetNamepublic static java.lang.String CHARSET_ENCODING
protected java.lang.String localIdentification
protected java.lang.StringBuffer remoteIdentification
protected boolean receivedRemoteIdentification
protected boolean sentLocalIdentification
protected byte[] localkex
protected byte[] remotekex
protected byte[] sessionIdentifier
protected java.util.UUID uuid
protected Service activeService
protected static final int SSH_MSG_SERVICE_REQUEST
public static final int SSH_MSG_SERVICE_ACCEPT
protected boolean completedFirstKeyExchange
protected java.util.Date disconnectStarted
public static final int NEGOTIATING_PROTOCOL
public static final int PERFORMING_KEYEXCHANGE
public static final int CONNECTED
public static final int DISCONNECTED
#getLastError(),
Constant Field Valuesprotected SshPublicKey hostKey
protected java.lang.String cipherCS
protected java.lang.String cipherSC
protected java.lang.String macCS
protected java.lang.String macSC
protected java.lang.String compressionCS
protected java.lang.String compressionSC
protected java.lang.String keyExchangeAlgorithm
protected java.lang.String publicKey
protected Connection<T extends SshContext> con
public static final int HOST_NOT_ALLOWED
public static final int PROTOCOL_ERROR
public static final int KEY_EXCHANGE_FAILED
public static final int RESERVED
public static final int MAC_ERROR
public static final int COMPRESSION_ERROR
public static final int SERVICE_NOT_AVAILABLE
public static final int PROTOCOL_VERSION_NOT_SUPPORTED
public static final int HOST_KEY_NOT_VERIFIABLE
public static final int CONNECTION_LOST
public static final int BY_APPLICATION
public static final int TOO_MANY_CONNECTIONS
public static final int AUTH_CANCELLED_BY_USER
public static final int NO_MORE_AUTH_METHODS_AVAILABLE
public static final int ILLEGAL_USER_NAME
protected T extends SshContext sshContext
protected SocketConnection socketConnection
public static java.lang.Object lock
public TransportProtocol(T sshContext, ConnectRequestFuture connectFuture)
java.io.IOExceptionprotected void transferState(TransportProtocol<? extends SshContext> transport)
public ConnectRequestFuture getConnectFuture()
getConnectFuture in interface ProtocolEnginepublic DisconnectRequestFuture getDisconnectFuture()
getDisconnectFuture in interface ProtocolEnginepublic SocketConnection getSocketConnection()
ProtocolEngineSocketConnection for this connection.getSocketConnection in interface ProtocolEnginepublic void addEventListener(TransportProtocolListener listener)
public java.net.SocketAddress getRemoteAddress()
public int getRemotePort()
public T getContext()
getContext in interface ProtocolEnginegetContext in interface SshTransport<T extends SshContext>getContext in class ExecutorOperationSupport<SshContext>public Connection<T> getConnection()
getConnection in interface ProtocolEngineprotected abstract boolean canConnect(SocketConnection connection)
protected abstract void onConnected()
protected abstract void onDisconnected()
public void onSocketConnect(SocketConnection connection)
ProtocolEngineonSocketConnect in interface ProtocolEngineconnection - SocketConnectionprotected boolean canSendKeyExchangeInit()
public boolean onSocketRead(java.nio.ByteBuffer incomingData)
onSocketRead in interface ProtocolEngineincomingData - ByteBufferpublic boolean isConnected()
isConnected in interface ProtocolEngineprotected void onRemoteIdentificationReceived(java.lang.String remoteIdentification)
public boolean wantsToWrite()
ProtocolEnginewantsToWrite in interface ProtocolEnginepublic int getQueueSizes()
public boolean idle()
idle in interface IdleStateListenerpublic SocketWriteCallback onSocketWrite(java.nio.ByteBuffer outgoingMessage)
onSocketWrite in interface ProtocolEngineoutgoingMessage - ByteBufferpublic int getState()
public java.net.SocketAddress getLocalAddress()
public int getLocalPort()
public java.lang.String getRemoteIdentification()
public java.lang.String getUUID()
protected abstract java.net.SocketAddress getConnectionAddress()
public void disconnect(int reason,
java.lang.String description)
disconnect in interface ProtocolEnginedisconnect in interface SshTransport<T extends SshContext>reason - description - java.io.IOExceptionpublic void onSocketClose()
onSocketClose in interface ProtocolEnginepublic java.security.SecureRandom getRND()
protected abstract void initializeKeyExchange(SshKeyExchange<T> keyExchange, boolean firstPacketFollows, boolean useFirstPacket) throws java.io.IOException, SshException
java.io.IOExceptionSshExceptionprotected abstract void onKeyExchangeInit()
throws SshException
SshExceptionprotected void keyExchangeInitialized()
protected abstract void disconnected()
protected abstract void onNewKeysReceived()
protected abstract boolean processTransportMessage(int msgid,
byte[] msg)
throws java.io.IOException,
SshException
java.io.IOExceptionSshExceptionpublic void processMessage(byte[] msg,
long sequenceNo)
throws SshException,
java.io.IOException,
WriteOperationRequest
msg - java.io.IOExceptionSshExceptionWriteOperationRequestprotected abstract void onNewKeysSent()
public void sendNewKeys()
sendNewKeys in interface SshTransport<T extends SshContext>public T getSshContext()
protected java.lang.String selectNegotiatedComponent(java.lang.String clientlist,
java.lang.String serverlist)
throws java.io.IOException
java.io.IOExceptionprotected void completeKeyExchange(SshKeyExchange<T> keyExchange)
protected void generateNewKeysServerOut()
protected void generateNewKeysServerIn()
protected void generateNewKeysClientOut()
protected void generateNewKeysClientIn()
public java.lang.String getCipherCS()
public java.lang.String getCipherSC()
public java.lang.String getMacCS()
public java.lang.String getMacSC()
public java.lang.String getCompressionCS()
public java.lang.String getCompressionSC()
public void postMessage(SshMessage msg)
postMessage in interface SshTransport<T extends SshContext>public void postMessage(SshMessage msg, boolean kex)
postMessage in interface SshTransport<T extends SshContext>public byte[] getSessionKey()
public static byte[] getBytes(java.lang.String str,
java.lang.String charset)
public void kill()
public java.lang.String getHostKeyAlgorithm()
public SshPublicKey getHostKey()
public java.lang.String getKeyExchangeAlgorithm()
public java.lang.String[] getRemoteKeyExchanges()
public java.lang.String[] getRemotePublicKeys()
public java.lang.String[] getRemoteCiphersCS()
public java.lang.String[] getRemoteCiphersSC()
public java.lang.String[] getRemoteMacsCS()
public java.lang.String[] getRemoteMacsSC()
public java.lang.String[] getRemoteCompressionsCS()
public java.lang.String[] getRemoteCompressionsSC()
public boolean hasCompletedKeyExchange()
public ExecutorOperationSupport<?> getExecutor()
getExecutor in interface ProtocolEnginepublic void registerIdleStateListener(IdleStateListener listener)
public void removeIdleStateListener(IdleStateListener listener)
public void resetIdleState(IdleStateListener listener)
public boolean isSelectorThread()
public java.lang.String getKeyExchangeInUse()
public java.lang.String getHostKeyInUse()
public java.lang.String getLocalIdentification()
Copyright © 2021. All rights reserved.