public class TransportProtocol extends Object implements ProtocolEngine, IdleStateListener, AbstractServerTransport
Modifier and Type | Field and Description |
---|---|
static int |
AUTH_CANCELLED_BY_USER
Disconnect reason: Authentication was cancelled
|
static int |
BY_APPLICATION
Disconnect reason: The application disconnected
|
static String |
CHARSET_ENCODING
Character set encoding.
|
static int |
COMPRESSION_ERROR
Disconnect reason: A compression error occurred
|
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.
|
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
|
static int |
ILLEGAL_USER_NAME
Disconnect reason: The user's name is illegal
|
static int |
KEY_EXCHANGE_FAILED
Disconnect reason: Key exchange failed
|
static Object |
lock |
static int |
MAC_ERROR
Disconnect reason: An error occurred verifying the MAC
|
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
|
static int |
RESERVED
Disconnect reason: Reserved
|
static int |
SERVICE_NOT_AVAILABLE
Disconnect reason: The requested service is not available
|
static int |
TOO_MANY_CONNECTIONS
Disconnect reason: Too many connections, try later
|
Constructor and Description |
---|
TransportProtocol(SshContext sshContext)
Create a default transport protocol instance in CLIENT_MODE.
|
Modifier and Type | Method and Description |
---|---|
void |
addChannelTask(ConnectionAwareTask task) |
void |
addEventListener(TransportProtocolListener listener) |
void |
addIncomingTask(ConnectionAwareTask r) |
void |
addOutgoingTask(ConnectionAwareTask r) |
void |
disableIdleTimeout() |
void |
disconnect(int reason,
String description)
Disconnect from the remote host.
|
void |
doPostMessage(SshMessage msg,
boolean kex) |
void |
enableCompression() |
void |
enableIdleTimeout() |
void |
forceDisconnect() |
String |
getCipherCS() |
String |
getCipherSC() |
String |
getCompressionCS() |
String |
getCompressionSC() |
Connection |
getConnection() |
SshContext |
getContext() |
String |
getHostKeyInUse() |
String |
getKeyExchange() |
String |
getKeyExchangeInUse() |
SocketAddress |
getLocalAddress()
Returns the local address to which the remote socket is connected.
|
int |
getLocalPort()
Returns the local port to which the remote socket is connected.
|
String |
getMacCS() |
String |
getMacSC() |
int |
getQueueSizes() |
SocketAddress |
getRemoteAddress() |
String |
getRemoteIdentification() |
int |
getRemotePort()
Returns the remote port of the connected socket.
|
SecureRandom |
getRND()
Gets the secure random number generator for this transport.
|
byte[] |
getSessionKey() |
SocketConnection |
getSocketConnection()
Get the
SocketConnection for this connection. |
SshContext |
getSshContext() |
int |
getState() |
String |
getUUID() |
boolean |
idle()
Called when the selector framework is idle.
|
boolean |
isConnected()
Determine if the protocol is still connected
|
byte[] |
makeSshKey(char chr,
int sizeRequired) |
void |
onSocketClose()
Disconnects everything internally
|
void |
onSocketConnect(SocketConnection connection)
The socket is connected and the protocol can now start.
|
boolean |
onSocketRead(ByteBuffer incomingData)
Called when the socket channel is reported to be ready for reading.
|
SocketWriteCallback |
onSocketWrite(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 |
sendNewKeys() |
boolean |
wantsToWrite()
Determines whether the protocol wants to write to the socket.
|
public static String CHARSET_ENCODING
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 Valuespublic 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
public static Object lock
public TransportProtocol(SshContext sshContext)
IOException
public SocketConnection getSocketConnection()
ProtocolEngine
SocketConnection
for this connection.getSocketConnection
in interface ProtocolEngine
public void addEventListener(TransportProtocolListener listener)
public SocketAddress getRemoteAddress()
public void enableCompression()
public int getRemotePort()
public SshContext getContext()
getContext
in interface ProtocolEngine
getContext
in interface AbstractServerTransport
public void onSocketConnect(SocketConnection connection)
ProtocolEngine
onSocketConnect
in interface ProtocolEngine
connection
- SocketConnectionpublic boolean onSocketRead(ByteBuffer incomingData)
onSocketRead
in interface ProtocolEngine
incomingData
- ByteBufferpublic boolean isConnected()
isConnected
in interface ProtocolEngine
public boolean wantsToWrite()
ProtocolEngine
wantsToWrite
in interface ProtocolEngine
public int getQueueSizes()
public boolean idle()
idle
in interface IdleStateListener
public void disableIdleTimeout()
public void enableIdleTimeout()
public SocketWriteCallback onSocketWrite(ByteBuffer outgoingMessage)
onSocketWrite
in interface ProtocolEngine
outgoingMessage
- ByteBufferpublic int getState()
public SocketAddress getLocalAddress()
public int getLocalPort()
public String getRemoteIdentification()
public String getUUID()
public void disconnect(int reason, String description)
disconnect
in interface ProtocolEngine
disconnect
in interface AbstractServerTransport
reason
- description
- IOException
public void forceDisconnect()
public void onSocketClose()
onSocketClose
in interface ProtocolEngine
public SecureRandom getRND()
public void sendNewKeys()
sendNewKeys
in interface AbstractServerTransport
public SshContext getSshContext()
public String getCipherCS()
public String getCipherSC()
public String getMacCS()
public String getMacSC()
public String getCompressionCS()
public String getCompressionSC()
public String getKeyExchange()
public void addOutgoingTask(ConnectionAwareTask r)
public void addIncomingTask(ConnectionAwareTask r)
public void postMessage(SshMessage msg)
public void postMessage(SshMessage msg, boolean kex)
postMessage
in interface AbstractServerTransport
public void doPostMessage(SshMessage msg, boolean kex)
public byte[] makeSshKey(char chr, int sizeRequired) throws SshException, IOException
SshException
IOException
public byte[] getSessionKey()
public Connection getConnection()
public String getKeyExchangeInUse()
public String getHostKeyInUse()
public void addChannelTask(ConnectionAwareTask task)
Copyright © 2024. All rights reserved.