public abstract class SshContext extends ProtocolContext implements ExecutorServiceProvider
SshEngine
.keepAlive, receiveBufferSize, reuseAddress, sendBufferSize, tcpNoDelay
Constructor and Description |
---|
SshContext(ComponentManager componentManager)
Constructs a default context but does not set the daemon
|
SshContext(SshEngine daemon,
ComponentManager componentManager)
Constructs a default context
|
Modifier and Type | Method and Description |
---|---|
void |
addOperationListener(ExecutorOperationListener listener) |
protected abstract void |
configureKeyExchanges() |
abstract ProtocolEngine |
createEngine(ConnectRequestFuture connectFuture)
Create a protocol engine.
|
void |
enableFIPSMode() |
ByteBufferPool |
getByteBufferPool() |
abstract ChannelFactory<? extends SshContext> |
getChannelFactory() |
int |
getChannelLimit()
Get the maximum number of open channels allowed by each client.
|
String |
getCiphersCS() |
String |
getCiphersSC()
Get the ciphers for the Server->Client stream.
|
ComponentManager |
getComponentManager() |
int |
getCompressionLevel()
Get the current compression level
|
abstract ConnectionManager<? extends SshContext> |
getConnectionManager() |
SshEngineContext |
getDaemonContext() |
SshEngine |
getEngine()
Get the instance of the SSHD for this context.
|
List<ExecutorOperationListener> |
getExecutorListeners() |
ExecutorService |
getExecutorService() |
int |
getForwardingBufferMaxQueueCount() |
abstract ForwardingManager<? extends SshContext> |
getForwardingManager() |
ForwardingPolicy |
getForwardingPolicy() |
abstract GlobalRequestHandler<? extends SshContext> |
getGlobalRequestHandler(String requestname) |
int |
getIdleAuthenticationTimeoutSeconds() |
int |
getIdleConnectionTimeoutSeconds()
Should the connection be disconnected on session timeout?
|
int |
getKeepAliveDataMaxLength()
Get the maximum data length for the keep-alive packet.
|
int |
getKeepAliveInterval()
Get the current keep-alive interval (in seconds).
|
int |
getKeyExchangePacketLimit()
Get the number of packets to send before a key exchange is forced
|
String |
getKeyExchanges()
Get the ciphers for the Server->Client stream.
|
int |
getKeyExchangeTransferLimit()
Get the number of bytes to transfer before a key exchange is forced.
|
Locale |
getLocale() |
String |
getMacsCS()
Get the ciphers for the Client->Server stream.
|
String |
getMacsSC()
Get the ciphers for the Server->Client stream.
|
int |
getMaxAuthentications()
Get the maximum number of failed authentications allowed for each
connection.
|
int |
getMaximumPacketLength()
Get the maximum supported length of an SSH packet.
|
int |
getMaximumSocketsBacklogPerRemotelyForwardedConnection() |
int |
getMinDHGroupExchangeKeySize() |
String |
getPreferredCipherCS()
Get the currently preferred cipher for the Client->Server stream.
|
String |
getPreferredCipherSC()
Get the currently preferred cipher for the Server->Client stream.
|
String |
getPreferredCompressionCS()
Get the currently preferred compression for the Client->Server stream.
|
String |
getPreferredCompressionSC()
Get the currently preferred compression for the Server->Client stream.
|
String |
getPreferredKeyExchange()
Get the currently preferred key exchange method.
|
String |
getPreferredMacCS()
Get the currently preferred mac for the Client->Server stream.
|
String |
getPreferredMacSC()
Get the currently supported mac for the Server-Client stream.
|
abstract String |
getPreferredPublicKey() |
String |
getPublicKeys()
Get the ciphers for the Server->Client stream.
|
boolean |
getRemoteForwardingCancelKillsTunnels()
Determines whether the cancellation of a remote forwarding drops
currently active tunnels
|
SocketConnectionFactory |
getSocketConnectionFactory() |
String |
getSoftwareVersionComments()
Get the software/version/comments field that is to be used in the SSH
protocols negotiation procedure.
|
abstract String |
getSupportedPublicKeys() |
void |
init(SshEngine daemon)
Initialise the SshContext by setting the daemon
|
protected String |
listPublicKeys(String... keys) |
void |
removeOperationListener(ExecutorOperationListener listener) |
void |
setChannelLimit(int maxChannels)
Set the maximum number of open channels allowed by each client (defaults
to 100).
|
void |
setCipherPreferredPositionCS(String name,
int position) |
void |
setCipherPreferredPositionSC(String name,
int position) |
void |
setCompressionLevel(int compressionLevel)
Set the compression level to use if compression is enabled
|
void |
setForwardingBufferMaxQueueCount(int forwardingBufferMaxQueueCount) |
void |
setForwardingPolicy(ForwardingPolicy forwardingPolicy) |
void |
setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds) |
void |
setIdleConnectionTimeoutSeconds(int idleConnectionTimeout)
Inform the context that the connection should be disconnected on session
timeout
|
void |
setKeepAliveDataMaxLength(int keepAliveDataMaxLength)
Set the maximum data length for the keep-alive packet.
|
void |
setKeepAliveInterval(int keepAliveInterval)
Set the keep-alive interval (in seconds).
|
void |
setKeyExchangePacketLimit(int MAX_NUM_PACKETS_BEFORE_REKEY)
This tells the server how many packets to use before a key exchange.
|
void |
setKeyExchangePreferredPosition(String name,
int position) |
void |
setKeyExchangeTransferLimit(int MAX_NUM_BYTES_BEFORE_REKEY)
This limit tells the server when to force a key exchange.
|
void |
setLocale(Locale locale) |
void |
setMacPreferredPositionCS(String name,
int position) |
void |
setMacPreferredPositionSC(String name,
int position) |
void |
setMaxAuthentications(int maxAuthentications)
Set the maximum number of failed authentications allowed for each
connection.
|
void |
setMaximumPacketLength(int maximumPacketLength)
Set the maximum supported length of an SSH packet.
|
void |
setMaximumSocketsBacklogPerRemotelyForwardedConnection(int maximumSocketsBacklogPerRemotelyForwardedConnection) |
void |
setMinDHGroupExchangeKeySize(int minDHGroupExchangeKeySize) |
void |
setPreferredCipherCC(String[] order)
Set the preferred CS cipher order
|
void |
setPreferredCipherCS(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherCS(String name)
Set the preferred cipher for the Client->Server stream.
|
void |
setPreferredCipherSC(int[] order)
Set the preferred SC cipher order
|
void |
setPreferredCipherSC(String name)
Set the preferred cipher for the Server->Client stream.
|
void |
setPreferredCipherSC(String[] order)
Set the preferred SC cipher order
|
void |
setPreferredCompressionCS(String name)
Set the preferred compression for the Client->Server stream.
|
void |
setPreferredCompressionSC(String name)
Set the preferred compression for the Server->Client stream.
|
void |
setPreferredKeyExchange(String name)
Set the preferred key exchange method.
|
void |
setPreferredKeyExchange(String[] order) |
void |
setPreferredMacCS(int[] order)
Set the preferred CS Mac order
|
void |
setPreferredMacCS(String name)
Set the preferred MAC for the Client->Server stream.
|
void |
setPreferredMacCS(String[] order) |
void |
setPreferredMacSC(int[] order)
Set the preferred SC Mac order
|
void |
setPreferredMacSC(String name)
Set the preferred mac for the Server->Client stream.
|
void |
setPreferredMacSC(String[] order) |
void |
setPublicKeyPreferredPosition(String name,
int position) |
void |
setRemoteForwardingCancelKillsTunnels(boolean killTunnelsOnRemoteForwardingCancel)
When the user cancels a remote forwarding should active tunnels be
dropped?
|
void |
setSocketConnectionFactory(SocketConnectionFactory socketConnectionFactory) |
void |
setSoftwareVersionComments(String softwareVersionComments)
Set the current implementations software/version/comments field that is
used during the SSH protocols negotiation procedure.
|
void |
shutdown() |
ComponentFactory<SshCipher> |
supportedCiphersCS()
Returns a factory implementation that enables configuration of the
available ciphers.
|
ComponentFactory<SshCipher> |
supportedCiphersSC() |
ComponentFactory<SshCompression> |
supportedCompressionsCS()
Get the supported compression algorithms.
|
ComponentFactory<SshCompression> |
supportedCompressionsSC() |
ComponentFactory<SshKeyExchange<? extends SshContext>> |
supportedKeyExchanges()
Get the supported key exchange methods.
|
ComponentFactory<SshHmac> |
supportedMacsCS()
Get the supported message authentication algorithms.
|
ComponentFactory<SshHmac> |
supportedMacsSC() |
ComponentFactory<SshPublicKey> |
supportedPublicKeys() |
createConnection, createConnectionImpl, getReceiveBufferSize, getSendBufferSize, getSocketOptionKeepAlive, getSocketOptionReuseAddress, getSocketOptionTcpNoDelay, setReceiveBufferSize, setSendBufferSize, setSocketHandlerImpl, setSocketOptionKeepAlive, setSocketOptionReuseAddress, setSocketOptionTcpNoDelay
public static final String CIPHER_TRIPLEDES_CBC
public static final String CIPHER_TRIPLEDES_CTR
public static final String CIPHER_BLOWFISH_CBC
public static final String CIPHER_AES128_CBC
public static final String CIPHER_AES192_CBC
public static final String CIPHER_AES256_CBC
public static final String CIPHER_AES128_CTR
public static final String CIPHER_AES192_CTR
public static final String CIPHER_AES256_CTR
public static final String CIPHER_ARCFOUR
public static final String CIPHER_ARCFOUR_128
public static final String CIPHER_ARCFOUR_256
public static final String HMAC_SHA1
public static final String HMAC_SHA1_ETM
public static final String HMAC_SHA1_96
public static final String HMAC_MD5
public static final String HMAC_MD5_ETM
public static final String HMAC_MD5_96
public static final String HMAC_SHA256
public static final String HMAC_SHA256_ETM
public static final String HMAC_SHA256_96
public static final String HMAC_SHA512
public static final String HMAC_SHA512_ETM
public static final String HMAC_SHA512_96
public static final String HMAC_RIPEMD160
public static final String HMAC_RIPEMD160_ETM
public static final String COMPRESSION_NONE
public static final String COMPRESSION_ZLIB
public static final String KEX_DIFFIE_HELLMAN_GROUP1_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1
public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256
public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA1
public static final String PUBLIC_KEY_SSHDSS
public static final String PUBLIC_KEY_SSHRSA
public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_256
public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_384
public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_521
public static final String PASSWORD_AUTHENTICATION
public static final String PUBLICKEY_AUTHENTICATION
public static final String KEYBOARD_INTERACTIVE_AUTHENTICATION
protected int maximumSocketsBacklogPerRemotelyForwardedConnection
protected SocketConnectionFactory socketConnectionFactory
protected ComponentFactory<SshCompression> compressionsCS
protected ComponentFactory<SshCompression> compressionsSC
protected ComponentFactory<SshCipher> ciphersCS
protected ComponentFactory<SshCipher> ciphersSC
protected ComponentFactory<SshKeyExchange<? extends SshContext>> keyExchanges
protected ComponentFactory<SshHmac> macCS
protected ComponentFactory<SshHmac> macSC
protected ComponentFactory<SshPublicKey> publicKeys
protected String prefCipherCS
protected String prefCipherSC
protected String prefMacCS
protected String prefMacSC
protected String prefCompressionCS
protected String prefCompressionSC
protected String prefKeyExchange
protected String prefPublicKey
protected int maxChannels
protected int maxAuthentications
protected int compressionLevel
protected int maximumPacketLength
protected int MAX_NUM_PACKETS_BEFORE_REKEY
protected int MAX_NUM_BYTES_BEFORE_REKEY
protected SshEngine daemon
protected String softwareVersionComments
protected boolean killTunnelsOnRemoteForwardingCancel
protected int idleConnectionTimeout
protected int idleAuthenticationTimeoutSeconds
protected int keepAliveInterval
protected int keepAliveDataMaxLength
protected static ExecutorService executor
protected int forwardingBufferMaxQueueCount
protected Locale locale
protected ByteBufferPool byteBufferPool
protected ForwardingPolicy forwardingPolicy
protected int minDHGroupExchangeKeySize
public SshContext(ComponentManager componentManager) throws IOException
componentManager
- IOException
public SshContext(SshEngine daemon, ComponentManager componentManager) throws IOException
componentManager
- IOException
public void init(SshEngine daemon)
public abstract ConnectionManager<? extends SshContext> getConnectionManager()
public abstract ProtocolEngine createEngine(ConnectRequestFuture connectFuture) throws IOException
ProtocolContext
createEngine
in class ProtocolContext
IOException
public abstract String getSupportedPublicKeys()
protected abstract void configureKeyExchanges()
public abstract String getPreferredPublicKey()
public abstract ChannelFactory<? extends SshContext> getChannelFactory()
public ComponentManager getComponentManager()
public void addOperationListener(ExecutorOperationListener listener)
public void removeOperationListener(ExecutorOperationListener listener)
public List<ExecutorOperationListener> getExecutorListeners()
getExecutorListeners
in interface ExecutorServiceProvider
public void setSocketConnectionFactory(SocketConnectionFactory socketConnectionFactory)
setSocketConnectionFactory
in class ProtocolContext
public SocketConnectionFactory getSocketConnectionFactory()
getSocketConnectionFactory
in class ProtocolContext
public abstract GlobalRequestHandler<? extends SshContext> getGlobalRequestHandler(String requestname)
public SshEngine getEngine()
public void setChannelLimit(int maxChannels)
maxChannels
- public int getChannelLimit()
public int getMaxAuthentications()
public void setMaxAuthentications(int maxAuthentications)
maxAuthentications
- public ComponentFactory<SshCipher> supportedCiphersCS()
Returns a factory implementation that enables configuration of the available ciphers.
The standard default ciphers installed are 3DES and Blowfish, however the
J2SSH Maverick API on which this server is based also supports a number
of optional ciphers AES, CAST and Twofish. These can be installed by
adding the sshtools-cipher.jar to your class path and using the
following code within your SSHD
SshDaemon#configure(ConfigurationContext)
method.
// import the cipher package import com.sshtools.cipher.*; // Add AES context.supportedCiphers().add(AES128Cbc.AES128_CBC, AES128Cbc.class); context.supportedCiphers().add(AES192Cbc.AES192_CBC, AES192Cbc.class); context.supportedCiphers().add(AES256Cbc.AES256_CBC, AES256Cbc.class); // Add Twofish - note the 256 bit cipher has two different entries to maintain backwards compatibility context.supportedCiphers().add(Twofish128Cbc.TWOFISH128_CBC, Twofish128Cbc.class); context.supportedCiphers().add(Twofish192Cbc.TWOFISH192_CBC, Twofish192Cbc.class); context.supportedCiphers().add(Twofish256Cbc.TWOFISH256_CBC, Twofish256Cbc.class); context.supportedCiphers().add(Twofish256Cbc.TWOFISH_CBC, Twofish256Cbc.class); // Add CAST context.supportedCiphers().add(CAST128Cbc.CAST128_CBC, CAST128Cbc.class);
public ComponentFactory<SshCipher> supportedCiphersSC()
public String getPreferredCipherCS()
public void setPreferredCipherCS(String name) throws IOException, SshException
Set the preferred cipher for the Client->Server stream.
Use the static fields available within this class (or the com.sshtools.cipher classes) to identify the correct cipher.
context.setPreferredCipherCS(ConfigurationContext.CIPHER_BLOWFISH_CBC);
name
- IOException
- if the cipher is not supportedSshException
public String getPreferredCipherSC()
public String getSoftwareVersionComments()
public void setSoftwareVersionComments(String softwareVersionComments)
softwareVersionComments
- public void setPreferredCipherSC(String name) throws IOException, SshException
Set the preferred cipher for the Server->Client stream.
Use the static fields available within this class (or the com.sshtools.cipher classes) to identify the correct cipher.
context.setPreferredCipherSC(ConfigurationContext.CIPHER_BLOWFISH_CBC);
name
- IOException
SshException
public ComponentFactory<SshHmac> supportedMacsCS()
Get the supported message authentication algorithms.
There are no optional MAC algorithms currently available and this method is supplied in preperation for future enhancements.
public ComponentFactory<SshHmac> supportedMacsSC()
public String getPreferredMacCS()
public void setPreferredMacCS(String name) throws IOException, SshException
Set the preferred MAC for the Client->Server stream.
Use the static fields available within this class to identify the correct MAC.
context.setPreferredMacCS(ConfigurationContext.HMAC_MD5);
name
- IOException
SshException
public String getPreferredMacSC()
public void setRemoteForwardingCancelKillsTunnels(boolean killTunnelsOnRemoteForwardingCancel)
killTunnelsOnRemoteForwardingCancel
- booleanpublic boolean getRemoteForwardingCancelKillsTunnels()
public void setPreferredMacSC(String name) throws IOException, SshException
Set the preferred mac for the Server->Client stream.
Use the static fields available within this class to identify the correct MAC.
context.setPreferredMacCS(ConfigurationContext.HMAC_MD5);
name
- IOException
SshException
public ComponentFactory<SshCompression> supportedCompressionsCS()
Get the supported compression algorithms.
There are no optional compression algorithms currently available and this method is supplied in preperation for future enhancements.
public ComponentFactory<SshCompression> supportedCompressionsSC()
public String getPreferredCompressionCS()
public void setPreferredCompressionCS(String name) throws IOException
Set the preferred compression for the Client->Server stream.
It is recommended that you do not set the preferred compression so that the client has control over the compression selection.
name
- IOException
public String getPreferredCompressionSC()
public void setPreferredCompressionSC(String name) throws IOException
Set the preferred compression for the Server->Client stream.
It is recommended that you do not set the preferred compression so that the client has control over the compression selection.
name
- IOException
public ComponentFactory<SshKeyExchange<? extends SshContext>> supportedKeyExchanges()
Get the supported key exchange methods.
There are no optional key exchange algorithms currently available and this method is supplied in preperation for future enhancements.
public String getPreferredKeyExchange()
public void setPreferredKeyExchange(String name) throws IOException, SshException
Set the preferred key exchange method.
There is only one supported key exchange algorithm and as such this method is supplied in preperation for future enhancements.
name
- IOException
SshException
public void setCompressionLevel(int compressionLevel)
compressionLevel
- intpublic int getCompressionLevel()
public int getMaximumSocketsBacklogPerRemotelyForwardedConnection()
public void setMaximumSocketsBacklogPerRemotelyForwardedConnection(int maximumSocketsBacklogPerRemotelyForwardedConnection)
public String getCiphersSC()
public String getCiphersCS()
public String getMacsCS()
public String getMacsSC()
public String getPublicKeys()
public String getKeyExchanges()
public void setPreferredCipherSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherSC(String[] order) throws SshException
order
- SshException
public void setPreferredCipherCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredCipherCC(String[] order) throws SshException
order
- SshException
public void setPreferredMacSC(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredMacSC(String[] order) throws SshException
order
- SshException
public void setPreferredKeyExchange(String[] order) throws SshException
order
- SshException
public void setPreferredMacCS(int[] order) throws SshException
order
- , list of indices to be moved to the top.SshException
public void setPreferredMacCS(String[] order) throws SshException
SshException
public void setCipherPreferredPositionCS(String name, int position) throws SshException
SshException
public void setCipherPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionSC(String name, int position) throws SshException
SshException
public void setMacPreferredPositionCS(String name, int position) throws SshException
SshException
public void setPublicKeyPreferredPosition(String name, int position) throws SshException
SshException
public void setKeyExchangePreferredPosition(String name, int position) throws SshException
SshException
public void setMaximumPacketLength(int maximumPacketLength)
maximumPacketLength
- intpublic int getMaximumPacketLength()
public void setKeyExchangeTransferLimit(int MAX_NUM_BYTES_BEFORE_REKEY)
MAX_NUM_BYTES_BEFORE_REKEY
- intpublic void setKeyExchangePacketLimit(int MAX_NUM_PACKETS_BEFORE_REKEY)
MAX_NUM_PACKETS_BEFORE_REKEY
- intpublic int getKeyExchangeTransferLimit()
public int getKeyExchangePacketLimit()
public int getIdleConnectionTimeoutSeconds()
public void setIdleConnectionTimeoutSeconds(int idleConnectionTimeout)
idleConnectionTimeout
- public ComponentFactory<SshPublicKey> supportedPublicKeys()
public int getKeepAliveInterval()
public void setKeepAliveInterval(int keepAliveInterval)
keepAliveInterval
- public int getKeepAliveDataMaxLength()
public void setKeepAliveDataMaxLength(int keepAliveDataMaxLength)
keepAliveDataMaxLength
- public void setLocale(Locale locale)
public Locale getLocale()
public void enableFIPSMode() throws SshException
SshException
public ExecutorService getExecutorService()
getExecutorService
in interface ExecutorServiceProvider
public void shutdown()
shutdown
in class ProtocolContext
public ByteBufferPool getByteBufferPool()
public int getForwardingBufferMaxQueueCount()
public void setForwardingBufferMaxQueueCount(int forwardingBufferMaxQueueCount)
public ForwardingPolicy getForwardingPolicy()
public void setForwardingPolicy(ForwardingPolicy forwardingPolicy)
public SshEngineContext getDaemonContext()
public int getIdleAuthenticationTimeoutSeconds()
public void setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds)
public int getMinDHGroupExchangeKeySize()
public void setMinDHGroupExchangeKeySize(int minDHGroupExchangeKeySize)
public abstract ForwardingManager<? extends SshContext> getForwardingManager()
Copyright © 2016. All rights reserved.