Class SshContext

java.lang.Object
com.sshtools.synergy.nio.ProtocolContext
com.sshtools.synergy.ssh.SshContext
All Implemented Interfaces:
Context, ExecutorServiceProvider

public abstract class SshContext extends ProtocolContext implements ExecutorServiceProvider, Context
This class defines an SSH context for listening interfaces on the SshEngine.
  • Field Details

    • CIPHER_TRIPLEDES_CBC

      public static final String CIPHER_TRIPLEDES_CBC
      See Also:
    • CIPHER_TRIPLEDES_CTR

      public static final String CIPHER_TRIPLEDES_CTR
      See Also:
    • CIPHER_BLOWFISH_CBC

      public static final String CIPHER_BLOWFISH_CBC
      See Also:
    • CIPHER_AES128_CBC

      public static final String CIPHER_AES128_CBC
      See Also:
    • CIPHER_AES192_CBC

      public static final String CIPHER_AES192_CBC
      See Also:
    • CIPHER_AES256_CBC

      public static final String CIPHER_AES256_CBC
      See Also:
    • CIPHER_AES128_CTR

      public static final String CIPHER_AES128_CTR
      See Also:
    • CIPHER_AES192_CTR

      public static final String CIPHER_AES192_CTR
      See Also:
    • CIPHER_AES256_CTR

      public static final String CIPHER_AES256_CTR
      See Also:
    • CIPHER_ARCFOUR

      public static final String CIPHER_ARCFOUR
      See Also:
    • CIPHER_ARCFOUR_128

      public static final String CIPHER_ARCFOUR_128
      See Also:
    • CIPHER_ARCFOUR_256

      public static final String CIPHER_ARCFOUR_256
      See Also:
    • CIPHER_AES_GCM_128

      public static final String CIPHER_AES_GCM_128
      See Also:
    • CIPHER_AES_GCM_256

      public static final String CIPHER_AES_GCM_256
      See Also:
    • HMAC_SHA1

      public static final String HMAC_SHA1
      SHA1 message authentication
      See Also:
    • HMAC_SHA1_ETM

      public static final String HMAC_SHA1_ETM
      See Also:
    • HMAC_SHA1_96

      public static final String HMAC_SHA1_96
      SHA1 96 bit message authentication
      See Also:
    • HMAC_MD5

      public static final String HMAC_MD5
      MD5 message authentication
      See Also:
    • HMAC_MD5_ETM

      public static final String HMAC_MD5_ETM
      See Also:
    • HMAC_MD5_96

      public static final String HMAC_MD5_96
      MD5 96 bit message authentication
      See Also:
    • HMAC_SHA256

      public static final String HMAC_SHA256
      See Also:
    • HMAC_SHA256_ETM

      public static final String HMAC_SHA256_ETM
      See Also:
    • HMAC_SHA256_96

      public static final String HMAC_SHA256_96
      See Also:
    • HMAC_SHA512

      public static final String HMAC_SHA512
      See Also:
    • HMAC_SHA512_ETM

      public static final String HMAC_SHA512_ETM
      See Also:
    • HMAC_SHA512_96

      public static final String HMAC_SHA512_96
      See Also:
    • HMAC_RIPEMD160

      public static final String HMAC_RIPEMD160
      See Also:
    • HMAC_RIPEMD160_ETM

      public static final String HMAC_RIPEMD160_ETM
      See Also:
    • COMPRESSION_NONE

      public static final String COMPRESSION_NONE
      Compression off
      See Also:
    • COMPRESSION_ZLIB

      public static final String COMPRESSION_ZLIB
      ZLIB compression
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP1_SHA1

      public static final String KEX_DIFFIE_HELLMAN_GROUP1_SHA1
      Constant for the algorithm name "diffie-hellman-group1-sha1".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1

      public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA1
      Constant for the algorithm name "diffie-hellman-group-exchange-sha1".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256

      public static final String KEX_DIFFIE_HELLMAN_GROUP_EXCHANGE_SHA256
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP14_SHA1

      public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA1
      Constant for the algorithm name "diffie-hellman-group14-sha1".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP14_SHA256

      public static final String KEX_DIFFIE_HELLMAN_GROUP14_SHA256
      Constant for the algorithm name "diffie-hellman-group14-sha256".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP15_SHA512

      public static final String KEX_DIFFIE_HELLMAN_GROUP15_SHA512
      Constant for the algorithm name "diffie-hellman-group15-sha512".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP16_SHA512

      public static final String KEX_DIFFIE_HELLMAN_GROUP16_SHA512
      Constant for the algorithm name "diffie-hellman-group16-sha512".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP17_SHA512

      public static final String KEX_DIFFIE_HELLMAN_GROUP17_SHA512
      Constant for the algorithm name "diffie-hellman-group17-sha512".
      See Also:
    • KEX_DIFFIE_HELLMAN_GROUP18_SHA512

      public static final String KEX_DIFFIE_HELLMAN_GROUP18_SHA512
      Constant for the algorithm name "diffie-hellman-group18-sha512".
      See Also:
    • KEX_DIFFIE_HELLMAN_ECDH_NISTP_256

      public static final String KEX_DIFFIE_HELLMAN_ECDH_NISTP_256
      See Also:
    • KEX_DIFFIE_HELLMAN_ECDH_NISTP_384

      public static final String KEX_DIFFIE_HELLMAN_ECDH_NISTP_384
      See Also:
    • KEX_DIFFIE_HELLMAN_ECDH_NISTP_521

      public static final String KEX_DIFFIE_HELLMAN_ECDH_NISTP_521
      See Also:
    • PUBLIC_KEY_SSHDSS

      public static final String PUBLIC_KEY_SSHDSS
      SSH2 DSA Public Key
      See Also:
    • PUBLIC_KEY_ED25519

      public static final String PUBLIC_KEY_ED25519
      ED25519 Public key
      See Also:
    • PUBLIC_KEY_ED448

      public static final String PUBLIC_KEY_ED448
      ED25519 Public key
      See Also:
    • PUBLIC_KEY_SSHRSA

      public static final String PUBLIC_KEY_SSHRSA
      SSH2 RSA Public Key
      See Also:
    • PUBLIC_KEY_ECDSA_SHA2_NISPTP_256

      public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_256
      ECDSA 256 bit Public Key
      See Also:
    • PUBLIC_KEY_ECDSA_SHA2_NISPTP_384

      public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_384
      ECDSA 384 bit Public Key
      See Also:
    • PUBLIC_KEY_ECDSA_SHA2_NISPTP_521

      public static final String PUBLIC_KEY_ECDSA_SHA2_NISPTP_521
      ECDSA 521 bit Public Key
      See Also:
    • PUBLIC_KEY_RSA_SHA256

      public static final String PUBLIC_KEY_RSA_SHA256
      RSA key with SHA256 signature
      See Also:
    • PUBLIC_KEY_RSA_SHA512

      public static final String PUBLIC_KEY_RSA_SHA512
      RSA key with SHA512 signature
      See Also:
    • PASSWORD_AUTHENTICATION

      public static final String PASSWORD_AUTHENTICATION
      Identifier for password authentication
      See Also:
    • PUBLICKEY_AUTHENTICATION

      public static final String PUBLICKEY_AUTHENTICATION
      Identifier for public key authentication
      See Also:
    • KEYBOARD_INTERACTIVE_AUTHENTICATION

      public static final String KEYBOARD_INTERACTIVE_AUTHENTICATION
      See Also:
    • maximumSocketsBacklogPerRemotelyForwardedConnection

      protected int maximumSocketsBacklogPerRemotelyForwardedConnection
    • socketConnectionFactory

      protected SocketConnectionFactory socketConnectionFactory
    • compressionsCS

      protected ComponentFactory<SshCompression> compressionsCS
    • compressionsSC

      protected ComponentFactory<SshCompression> compressionsSC
    • ciphersCS

      protected ComponentFactory<SshCipher> ciphersCS
    • ciphersSC

      protected ComponentFactory<SshCipher> ciphersSC
    • keyExchanges

      protected ComponentFactory<SshKeyExchange<? extends SshContext>> keyExchanges
    • macCS

      protected ComponentFactory<SshHmac> macCS
    • macSC

      protected ComponentFactory<SshHmac> macSC
    • publicKeys

      protected ComponentFactory<SshPublicKey> publicKeys
    • signatures

      protected ComponentFactory<SshPublicKey> signatures
    • prefCipherCS

      protected String prefCipherCS
    • prefCipherSC

      protected String prefCipherSC
    • prefMacCS

      protected String prefMacCS
    • prefMacSC

      protected String prefMacSC
    • prefCompressionCS

      protected String prefCompressionCS
    • prefCompressionSC

      protected String prefCompressionSC
    • prefKeyExchange

      protected String prefKeyExchange
    • prefPublicKey

      protected String prefPublicKey
    • maxChannels

      protected int maxChannels
    • compressionLevel

      protected int compressionLevel
    • maximumPacketLength

      protected int maximumPacketLength
    • MAX_NUM_PACKETS_BEFORE_REKEY

      protected long MAX_NUM_PACKETS_BEFORE_REKEY
    • MAX_NUM_BYTES_BEFORE_REKEY

      protected long MAX_NUM_BYTES_BEFORE_REKEY
    • daemon

      protected SshEngine daemon
    • softwareVersionComments

      protected String softwareVersionComments
    • extendedIdentificationSanitization

      protected boolean extendedIdentificationSanitization
    • killTunnelsOnRemoteForwardingCancel

      protected boolean killTunnelsOnRemoteForwardingCancel
    • sendIgnorePacketOnIdle

      protected boolean sendIgnorePacketOnIdle
    • idleConnectionTimeout

      protected int idleConnectionTimeout
    • idleAuthenticationTimeoutSeconds

      protected int idleAuthenticationTimeoutSeconds
    • keepAliveInterval

      protected int keepAliveInterval
    • keepAliveDataMaxLength

      protected int keepAliveDataMaxLength
    • executor

      protected static ExecutorService executor
    • locale

      protected Locale locale
    • byteBufferPool

      protected com.sshtools.common.util.ByteBufferPool byteBufferPool
    • minDHGroupExchangeKeySize

      protected int minDHGroupExchangeKeySize
    • preferredDHGroupExchangeKeySize

      protected int preferredDHGroupExchangeKeySize
    • maxDHGroupExchangeKeySize

      protected int maxDHGroupExchangeKeySize
    • componentManager

      protected ComponentManager componentManager
  • Constructor Details

  • Method Details

    • init

      public void init(SshEngine daemon)
      Initialise the SshContext by setting the daemon
    • getConnectionManager

      public abstract ConnectionManager<? extends SshContext> getConnectionManager()
    • createEngine

      public abstract ProtocolEngine createEngine(ConnectRequestFuture connectFuture) throws IOException
      Description copied from class: ProtocolContext
      Create a protocol engine.
      Specified by:
      createEngine in class ProtocolContext
      Returns:
      ProtocolEngine
      Throws:
      IOException
    • getSupportedPublicKeys

      public abstract String getSupportedPublicKeys()
    • configureKeyExchanges

      protected abstract void configureKeyExchanges()
    • getPreferredPublicKey

      public abstract String getPreferredPublicKey()
    • getChannelFactory

      public abstract ChannelFactory<? extends SshContext> getChannelFactory()
    • getPolicy

      public <P> P getPolicy(Class<P> clz)
      Specified by:
      getPolicy in interface Context
    • getPolicy

      public <P> P getPolicy(Class<P> clz, P defaultValue)
    • setPolicy

      public void setPolicy(Class<?> clz, Object policy)
      Specified by:
      setPolicy in interface Context
    • hasPolicy

      public boolean hasPolicy(Class<?> clz)
      Specified by:
      hasPolicy in interface Context
    • getComponentManager

      public ComponentManager getComponentManager()
      Specified by:
      getComponentManager in interface Context
    • addOperationListener

      public void addOperationListener(ExecutorOperationListener listener)
    • removeOperationListener

      public void removeOperationListener(ExecutorOperationListener listener)
    • getExecutorListeners

      public List<ExecutorOperationListener> getExecutorListeners()
      Specified by:
      getExecutorListeners in interface ExecutorServiceProvider
    • setSocketConnectionFactory

      public void setSocketConnectionFactory(SocketConnectionFactory socketConnectionFactory)
      Overrides:
      setSocketConnectionFactory in class ProtocolContext
    • getSocketConnectionFactory

      public SocketConnectionFactory getSocketConnectionFactory()
      Overrides:
      getSocketConnectionFactory in class ProtocolContext
    • getGlobalRequestHandler

      public abstract GlobalRequestHandler<? extends SshContext> getGlobalRequestHandler(String requestname)
    • getEngine

      public SshEngine getEngine()
      Get the instance of the SSHD for this context.
      Returns:
      Daemon
    • setChannelLimit

      public void setChannelLimit(int maxChannels)
      Set the maximum number of open channels allowed by each client (defaults to 100).
      Parameters:
      maxChannels -
    • getChannelLimit

      public int getChannelLimit()
      Get the maximum number of open channels allowed by each client.
      Returns:
      int
    • getSupportedSignatures

      public ComponentFactory<SshPublicKey> getSupportedSignatures()
    • supportedCiphersCS

      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);
       
      Returns:
      the component factory
    • supportedCiphersSC

      public ComponentFactory<SshCipher> supportedCiphersSC()
    • getPreferredCipherCS

      public String getPreferredCipherCS()
      Get the currently preferred cipher for the Client->Server stream.
      Returns:
      the preferred Client-Server cipher
    • setPreferredCipherCS

      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);

      The default cipher is 3DES

      Parameters:
      name -
      Throws:
      IOException - if the cipher is not supported
      SshException
    • getPreferredCipherSC

      public String getPreferredCipherSC()
      Get the currently preferred cipher for the Server->Client stream.
      Returns:
      the preferred Server-Client cipher
    • getSoftwareVersionComments

      public String getSoftwareVersionComments()
      Get the software/version/comments field that is to be used in the SSH protocols negotiation procedure.
      Returns:
      String
    • setSoftwareVersionComments

      public void setSoftwareVersionComments(String softwareVersionComments)
      Set the current implementations software/version/comments field that is used during the SSH protocols negotiation procedure. This value MUST consist of printable US-ASCII characters with the exception of whitespace and the minus sign (-) and be no longer than 200 characters.
      Parameters:
      softwareVersionComments -
    • setPreferredCipherSC

      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);

      The default cipher is 3DES

      Parameters:
      name -
      Throws:
      IOException
      SshException
    • supportedMacsCS

      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.

      Returns:
      the component factory
    • supportedMacsSC

      public ComponentFactory<SshHmac> supportedMacsSC()
    • getPreferredMacCS

      public String getPreferredMacCS()
      Get the currently preferred mac for the Client->Server stream.
      Returns:
      the preferred Client-Server mac
    • setPreferredMacCS

      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);

      The default MAC is HMAC_SHA1

      Parameters:
      name -
      Throws:
      IOException
      SshException
    • getPreferredMacSC

      public String getPreferredMacSC()
      Get the currently supported mac for the Server-Client stream.
      Returns:
      the preferred Server-Client mac
    • setRemoteForwardingCancelKillsTunnels

      public void setRemoteForwardingCancelKillsTunnels(boolean killTunnelsOnRemoteForwardingCancel)
      When the user cancels a remote forwarding should active tunnels be dropped?
      Parameters:
      killTunnelsOnRemoteForwardingCancel - boolean
    • getRemoteForwardingCancelKillsTunnels

      public boolean getRemoteForwardingCancelKillsTunnels()
      Determines whether the cancellation of a remote forwarding drops currently active tunnels
      Returns:
      boolean
    • isExtendedIdentificationSanitization

      public boolean isExtendedIdentificationSanitization()
    • setExtendedIdentificationSanitization

      public void setExtendedIdentificationSanitization(boolean extendedIdentificationSanitization)
    • setPreferredMacSC

      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);

      The default MAC is HMAC_SHA1

      Parameters:
      name -
      Throws:
      IOException
      SshException
    • supportedCompressionsCS

      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.

      Returns:
      the component factory
    • supportedCompressionsSC

      public ComponentFactory<SshCompression> supportedCompressionsSC()
    • getPreferredCompressionCS

      public String getPreferredCompressionCS()
      Get the currently preferred compression for the Client->Server stream.
      Returns:
      the preferred Client-Server compression
    • setPreferredCompressionCS

      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.

      Parameters:
      name -
      Throws:
      IOException
    • getPreferredCompressionSC

      public String getPreferredCompressionSC()
      Get the currently preferred compression for the Server->Client stream.
      Returns:
      the preferred Server->Client compression
    • setPreferredCompressionSC

      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.

      Parameters:
      name -
      Throws:
      IOException
    • supportedKeyExchanges

      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.

      Returns:
      the component factory
    • getPreferredKeyExchange

      public String getPreferredKeyExchange()
      Get the currently preferred key exchange method.
      Returns:
      the preferred key exhcange
    • setPreferredKeyExchange

      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.

      Parameters:
      name -
      Throws:
      IOException
      SshException
    • setCompressionLevel

      public void setCompressionLevel(int compressionLevel)
      Set the compression level to use if compression is enabled
      Parameters:
      compressionLevel - int
    • getCompressionLevel

      public int getCompressionLevel()
      Get the current compression level
      Returns:
      int
    • getMaximumSocketsBacklogPerRemotelyForwardedConnection

      public int getMaximumSocketsBacklogPerRemotelyForwardedConnection()
    • setMaximumSocketsBacklogPerRemotelyForwardedConnection

      public void setMaximumSocketsBacklogPerRemotelyForwardedConnection(int maximumSocketsBacklogPerRemotelyForwardedConnection)
    • getCiphersSC

      public String getCiphersSC()
      Get the ciphers for the Server->Client stream.
      Returns:
      the Server-Client ciphers in order of preference
    • getCiphersCS

      public String getCiphersCS()
    • getMacsCS

      public String getMacsCS()
      Get the ciphers for the Client->Server stream.
      Returns:
      the Client-Server ciphers in order of preference
    • getMacsSC

      public String getMacsSC()
      Get the ciphers for the Server->Client stream.
      Returns:
      the Server-Client ciphers in order of preference
    • getPublicKeys

      public String getPublicKeys()
      Get the ciphers for the Server->Client stream.
      Returns:
      the Server-Client ciphers in order of preference
    • getKeyExchanges

      public String getKeyExchanges()
      Get the ciphers for the Server->Client stream.
      Returns:
      the Server-Client ciphers in order of preference
    • setPreferredCipherSC

      public void setPreferredCipherSC(int[] order) throws SshException
      Set the preferred SC cipher order
      Parameters:
      order - , list of indices to be moved to the top.
      Throws:
      SshException
    • setPreferredCipherSC

      public void setPreferredCipherSC(String[] order) throws SshException
      Set the preferred SC cipher order
      Parameters:
      order -
      Throws:
      SshException
    • setPreferredCipherCS

      public void setPreferredCipherCS(int[] order) throws SshException
      Set the preferred SC cipher order
      Parameters:
      order - , list of indices to be moved to the top.
      Throws:
      SshException
    • setPreferredCipherCS

      public void setPreferredCipherCS(String[] order) throws SshException
      Set the preferred CS cipher order
      Parameters:
      order -
      Throws:
      SshException
    • setPreferredMacSC

      public void setPreferredMacSC(int[] order) throws SshException
      Set the preferred SC Mac order
      Parameters:
      order - , list of indices to be moved to the top.
      Throws:
      SshException
    • setPreferredMacSC

      public void setPreferredMacSC(String[] order) throws SshException
      Parameters:
      order -
      Throws:
      SshException
    • setPreferredKeyExchange

      public void setPreferredKeyExchange(String[] order) throws SshException
      Parameters:
      order -
      Throws:
      SshException
    • setPreferredMacCS

      public void setPreferredMacCS(int[] order) throws SshException
      Set the preferred CS Mac order
      Parameters:
      order - , list of indices to be moved to the top.
      Throws:
      SshException
    • setPreferredMacCS

      public void setPreferredMacCS(String[] order) throws SshException
      Throws:
      SshException
    • setCipherPreferredPositionCS

      public void setCipherPreferredPositionCS(String name, int position) throws SshException
      Throws:
      SshException
    • setCipherPreferredPositionSC

      public void setCipherPreferredPositionSC(String name, int position) throws SshException
      Throws:
      SshException
    • setMacPreferredPositionSC

      public void setMacPreferredPositionSC(String name, int position) throws SshException
      Throws:
      SshException
    • setMacPreferredPositionCS

      public void setMacPreferredPositionCS(String name, int position) throws SshException
      Throws:
      SshException
    • setPublicKeyPreferredPosition

      public void setPublicKeyPreferredPosition(String name, int position) throws SshException
      Throws:
      SshException
    • setKeyExchangePreferredPosition

      public void setKeyExchangePreferredPosition(String name, int position) throws SshException
      Throws:
      SshException
    • setMaximumPacketLength

      public void setMaximumPacketLength(int maximumPacketLength)
      Set the maximum supported length of an SSH packet.
      Parameters:
      maximumPacketLength - int
    • getMaximumPacketLength

      public int getMaximumPacketLength()
      Get the maximum supported length of an SSH packet.
      Specified by:
      getMaximumPacketLength in interface Context
      Returns:
      int
    • setKeyExchangeTransferLimit

      public void setKeyExchangeTransferLimit(long MAX_NUM_BYTES_BEFORE_REKEY)
      This limit tells the server when to force a key exchange.
      Parameters:
      MAX_NUM_BYTES_BEFORE_REKEY - int
    • setKeyExchangePacketLimit

      public void setKeyExchangePacketLimit(int MAX_NUM_PACKETS_BEFORE_REKEY)
      This tells the server how many packets to use before a key exchange.
      Parameters:
      MAX_NUM_PACKETS_BEFORE_REKEY - int
    • getKeyExchangeTransferLimit

      public long getKeyExchangeTransferLimit()
      Get the number of bytes to transfer before a key exchange is forced.
      Returns:
      int
    • getKeyExchangePacketLimit

      public long getKeyExchangePacketLimit()
      Get the number of packets to send before a key exchange is forced
      Returns:
      int
    • getIdleConnectionTimeoutSeconds

      public int getIdleConnectionTimeoutSeconds()
      Should the connection be disconnected on session timeout?
      Returns:
    • setIdleConnectionTimeoutSeconds

      public void setIdleConnectionTimeoutSeconds(int idleConnectionTimeout)
      Inform the context that the connection should be disconnected on session timeout
      Parameters:
      idleConnectionTimeout -
    • supportedPublicKeys

      public ComponentFactory<SshPublicKey> supportedPublicKeys()
    • getKeepAliveInterval

      public int getKeepAliveInterval()
      Get the current keep-alive interval (in seconds). The server sends an SSH_MSG_IGNORE every n seconds after no activity on a connection.
      Returns:
    • setKeepAliveInterval

      public void setKeepAliveInterval(int keepAliveInterval)
      Set the keep-alive interval (in seconds). The server sends an SSH_MSG_IGNORE message every n seconds after no activity on a connection.
      Parameters:
      keepAliveInterval -
    • getKeepAliveDataMaxLength

      public int getKeepAliveDataMaxLength()
      Get the maximum data length for the keep-alive packet.
      Returns:
    • setKeepAliveDataMaxLength

      public void setKeepAliveDataMaxLength(int keepAliveDataMaxLength)
      Set the maximum data length for the keep-alive packet. Default is 128, the actual number of bytes is random up to this maximum.
      Parameters:
      keepAliveDataMaxLength -
    • setLocale

      public void setLocale(Locale locale)
    • getLocale

      public Locale getLocale()
    • enableFIPSMode

      public void enableFIPSMode() throws SshException
      Throws:
      SshException
    • getExecutorService

      public ExecutorService getExecutorService()
      Specified by:
      getExecutorService in interface Context
      Specified by:
      getExecutorService in interface ExecutorServiceProvider
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in class ProtocolContext
    • getByteBufferPool

      public com.sshtools.common.util.ByteBufferPool getByteBufferPool()
      Specified by:
      getByteBufferPool in interface Context
    • getDaemonContext

      public SshEngineContext getDaemonContext()
    • getIdleAuthenticationTimeoutSeconds

      public int getIdleAuthenticationTimeoutSeconds()
    • setIdleAuthenticationTimeoutSeconds

      public void setIdleAuthenticationTimeoutSeconds(int idleAuthenticationTimeoutSeconds)
    • getMinDHGroupExchangeKeySize

      public int getMinDHGroupExchangeKeySize()
    • setMinDHGroupExchangeKeySize

      public void setMinDHGroupExchangeKeySize(int minDHGroupExchangeKeySize)
    • getForwardingManager

      public abstract ForwardingManager<? extends SshContext> getForwardingManager()
    • listPublicKeys

      protected String listPublicKeys(String... keys)
    • isSendIgnorePacketOnIdle

      public boolean isSendIgnorePacketOnIdle()
    • setSendIgnorePacketOnIdle

      public void setSendIgnorePacketOnIdle(boolean sendIgnorePacketOnIdle)
    • isHttpRedirect

      public boolean isHttpRedirect()
    • setHttpRedirect

      public void setHttpRedirect(boolean httpRedirect)
    • getHttpRedirectUrl

      public String getHttpRedirectUrl()
    • setHttpRedirectUrl

      public void setHttpRedirectUrl(String httpRedirectUrl)
    • getPreferredDHGroupExchangeKeySize

      public int getPreferredDHGroupExchangeKeySize()
    • setPreferredDHGroupExchangeKeySize

      public void setPreferredDHGroupExchangeKeySize(int preferredDHGroupExchangeKeySize)
    • getMaxDHGroupExchangeKeySize

      public int getMaxDHGroupExchangeKeySize()
    • setMaxDHGroupExchangeKeySize

      public void setMaxDHGroupExchangeKeySize(int maxDHGroupExchangeKeySize)
    • getForwardingPolicy

      public ForwardingPolicy getForwardingPolicy()
    • isSHA1SignaturesSupported

      public boolean isSHA1SignaturesSupported()
    • setSHA1SignaturesSupported

      public void setSHA1SignaturesSupported(boolean sha1SignaturesSupported)