Package net.schmizz.sshj
Class ConfigImpl
- java.lang.Object
-
- net.schmizz.sshj.ConfigImpl
-
- All Implemented Interfaces:
Config
- Direct Known Subclasses:
DefaultConfig
public class ConfigImpl extends java.lang.Object implements Config
-
-
Constructor Summary
Constructors Constructor Description ConfigImpl()
-
Method Summary
Modifier and Type Method Description java.util.List<Factory.Named<Cipher>>getCipherFactories()Retrieve the list of named factories forCipher.java.util.List<Factory.Named<Compression>>getCompressionFactories()Retrieve the list of named factories forCompression.java.util.List<Factory.Named<FileKeyProvider>>getFileKeyProviderFactories()Retrieve the list of named factories forFileKeyProvider.KeepAliveProvidergetKeepAliveProvider()java.util.List<Factory.Named<KeyAlgorithm>>getKeyAlgorithms()Retrieve the list of named factories forKeyAlgorithmjava.util.List<Factory.Named<KeyExchange>>getKeyExchangeFactories()Retrieve the list of named factories forKeyExchange.LoggerFactorygetLoggerFactory()java.util.List<Factory.Named<MAC>>getMACFactories()Retrieve the list of named factories forMAC.intgetMaxCircularBufferSize()Factory<Random>getRandomFactory()Retrieve theRandomfactory.java.lang.StringgetVersion()Returns the software version information for identification during SSH connection initialization.booleanisVerifyHostKeyCertificates()Returns true if host key certificates should be verified while connecting to the server.booleanisWaitForServerIdentBeforeSendingClientIdent()Gets whether the client should first wait for a received server ident, before sending the client ident.voidprioritizeSshRsaKeyAlgorithm()Modern servers neglect the key algorithm ssh-rsa.voidsetCipherFactories(java.util.List<Factory.Named<Cipher>> cipherFactories)Set the named factories forCipher.voidsetCipherFactories(Factory.Named<Cipher>... cipherFactories)voidsetCompressionFactories(java.util.List<Factory.Named<Compression>> compressionFactories)Set the named factories forCompression.voidsetCompressionFactories(Factory.Named<Compression>... compressionFactories)voidsetFileKeyProviderFactories(java.util.List<Factory.Named<FileKeyProvider>> fileKeyProviderFactories)Set the named factories forFileKeyProvider.voidsetFileKeyProviderFactories(Factory.Named<FileKeyProvider>... fileKeyProviderFactories)voidsetKeepAliveProvider(KeepAliveProvider keepAliveProvider)Set the provider that provides the keep-alive implementation.voidsetKeyAlgorithms(java.util.List<Factory.Named<KeyAlgorithm>> keyAlgorithms)Set the named factories forKeyAlgorithm.voidsetKeyExchangeFactories(java.util.List<Factory.Named<KeyExchange>> kexFactories)Set the named factories forKeyExchange.voidsetKeyExchangeFactories(Factory.Named<KeyExchange>... kexFactories)voidsetLoggerFactory(LoggerFactory loggerFactory)Sets the LoggerFactory to use.voidsetMACFactories(java.util.List<Factory.Named<MAC>> macFactories)Set the named factories forMAC.voidsetMACFactories(Factory.Named<MAC>... macFactories)voidsetMaxCircularBufferSize(int maxCircularBufferSize)voidsetRandomFactory(Factory<Random> randomFactory)Set the factory forRandom.voidsetVerifyHostKeyCertificates(boolean value)Sets whether the SSH client should verify host key certificates or not.voidsetVersion(java.lang.String version)Set the software version information for identification during SSH connection initialization.voidsetWaitForServerIdentBeforeSendingClientIdent(boolean waitForServerIdentBeforeSendingClientIdent)Sets whether the SSH client should wait for a received server ident, before sending the client ident.
-
-
-
Method Detail
-
getCipherFactories
public java.util.List<Factory.Named<Cipher>> getCipherFactories()
Description copied from interface:ConfigRetrieve the list of named factories forCipher.- Specified by:
getCipherFactoriesin interfaceConfig- Returns:
- a list of named
Cipherfactories
-
getCompressionFactories
public java.util.List<Factory.Named<Compression>> getCompressionFactories()
Description copied from interface:ConfigRetrieve the list of named factories forCompression.- Specified by:
getCompressionFactoriesin interfaceConfig- Returns:
- a list of named
Compressionfactories
-
getFileKeyProviderFactories
public java.util.List<Factory.Named<FileKeyProvider>> getFileKeyProviderFactories()
Description copied from interface:ConfigRetrieve the list of named factories forFileKeyProvider.- Specified by:
getFileKeyProviderFactoriesin interfaceConfig- Returns:
- a list of named
FileKeyProviderfactories
-
getKeyExchangeFactories
public java.util.List<Factory.Named<KeyExchange>> getKeyExchangeFactories()
Description copied from interface:ConfigRetrieve the list of named factories forKeyExchange.- Specified by:
getKeyExchangeFactoriesin interfaceConfig- Returns:
- a list of named
KeyExchangefactories
-
getMACFactories
public java.util.List<Factory.Named<MAC>> getMACFactories()
Description copied from interface:ConfigRetrieve the list of named factories forMAC.- Specified by:
getMACFactoriesin interfaceConfig- Returns:
- a list of named
MACfactories
-
getRandomFactory
public Factory<Random> getRandomFactory()
Description copied from interface:ConfigRetrieve theRandomfactory.- Specified by:
getRandomFactoryin interfaceConfig- Returns:
- the
Randomfactory
-
getVersion
public java.lang.String getVersion()
Description copied from interface:ConfigReturns the software version information for identification during SSH connection initialization. For example,"NET_3_0".- Specified by:
getVersionin interfaceConfig
-
setCipherFactories
public void setCipherFactories(Factory.Named<Cipher>... cipherFactories)
-
setCipherFactories
public void setCipherFactories(java.util.List<Factory.Named<Cipher>> cipherFactories)
Description copied from interface:ConfigSet the named factories forCipher.- Specified by:
setCipherFactoriesin interfaceConfig- Parameters:
cipherFactories- a list of named factories
-
setCompressionFactories
public void setCompressionFactories(Factory.Named<Compression>... compressionFactories)
-
setCompressionFactories
public void setCompressionFactories(java.util.List<Factory.Named<Compression>> compressionFactories)
Description copied from interface:ConfigSet the named factories forCompression.- Specified by:
setCompressionFactoriesin interfaceConfig- Parameters:
compressionFactories- a list of named factories
-
setFileKeyProviderFactories
public void setFileKeyProviderFactories(Factory.Named<FileKeyProvider>... fileKeyProviderFactories)
-
setFileKeyProviderFactories
public void setFileKeyProviderFactories(java.util.List<Factory.Named<FileKeyProvider>> fileKeyProviderFactories)
Description copied from interface:ConfigSet the named factories forFileKeyProvider.- Specified by:
setFileKeyProviderFactoriesin interfaceConfig- Parameters:
fileKeyProviderFactories- a list of named factories
-
setKeyExchangeFactories
public void setKeyExchangeFactories(Factory.Named<KeyExchange>... kexFactories)
-
setKeyExchangeFactories
public void setKeyExchangeFactories(java.util.List<Factory.Named<KeyExchange>> kexFactories)
Description copied from interface:ConfigSet the named factories forKeyExchange.- Specified by:
setKeyExchangeFactoriesin interfaceConfig- Parameters:
kexFactories- a list of named factories
-
setMACFactories
public void setMACFactories(Factory.Named<MAC>... macFactories)
-
setMACFactories
public void setMACFactories(java.util.List<Factory.Named<MAC>> macFactories)
Description copied from interface:ConfigSet the named factories forMAC.- Specified by:
setMACFactoriesin interfaceConfig- Parameters:
macFactories- a list of named factories
-
setRandomFactory
public void setRandomFactory(Factory<Random> randomFactory)
Description copied from interface:ConfigSet the factory forRandom.- Specified by:
setRandomFactoryin interfaceConfig- Parameters:
randomFactory- the factory
-
setVersion
public void setVersion(java.lang.String version)
Description copied from interface:ConfigSet the software version information for identification during SSH connection initialization. For example,"SSHJ_0_1".- Specified by:
setVersionin interfaceConfig- Parameters:
version- software version info
-
getKeepAliveProvider
public KeepAliveProvider getKeepAliveProvider()
- Specified by:
getKeepAliveProviderin interfaceConfig- Returns:
- The provider that creates the keep-alive implementation of choice.
-
setKeepAliveProvider
public void setKeepAliveProvider(KeepAliveProvider keepAliveProvider)
Description copied from interface:ConfigSet the provider that provides the keep-alive implementation.- Specified by:
setKeepAliveProviderin interfaceConfig- Parameters:
keepAliveProvider- keep-alive provider
-
isWaitForServerIdentBeforeSendingClientIdent
public boolean isWaitForServerIdentBeforeSendingClientIdent()
Description copied from interface:ConfigGets whether the client should first wait for a received server ident, before sending the client ident. NB: This is non-standard behaviour, and can potentially deadlock if the server also waits on the client ident. The default value is set to false.- Specified by:
isWaitForServerIdentBeforeSendingClientIdentin interfaceConfig- Returns:
- Whether to first wait for the server ident.
-
setWaitForServerIdentBeforeSendingClientIdent
public void setWaitForServerIdentBeforeSendingClientIdent(boolean waitForServerIdentBeforeSendingClientIdent)
Description copied from interface:ConfigSets whether the SSH client should wait for a received server ident, before sending the client ident. NB: This is non-standard behaviour, and can potentially deadlock if the server also waits on the client ident.- Specified by:
setWaitForServerIdentBeforeSendingClientIdentin interfaceConfig- Parameters:
waitForServerIdentBeforeSendingClientIdent- Whether to wait for the server ident.
-
getKeyAlgorithms
public java.util.List<Factory.Named<KeyAlgorithm>> getKeyAlgorithms()
Description copied from interface:ConfigRetrieve the list of named factories forKeyAlgorithm- Specified by:
getKeyAlgorithmsin interfaceConfig- Returns:
- a list of named
KeyAlgorithmfactories
-
setKeyAlgorithms
public void setKeyAlgorithms(java.util.List<Factory.Named<KeyAlgorithm>> keyAlgorithms)
Description copied from interface:ConfigSet the named factories forKeyAlgorithm.- Specified by:
setKeyAlgorithmsin interfaceConfig- Parameters:
keyAlgorithms- a list of named factories
-
getLoggerFactory
public LoggerFactory getLoggerFactory()
- Specified by:
getLoggerFactoryin interfaceConfig- Returns:
- The LoggerFactory the SSHClient will use.
-
getMaxCircularBufferSize
public int getMaxCircularBufferSize()
- Specified by:
getMaxCircularBufferSizein interfaceConfig
-
setMaxCircularBufferSize
public void setMaxCircularBufferSize(int maxCircularBufferSize)
- Specified by:
setMaxCircularBufferSizein interfaceConfig
-
setLoggerFactory
public void setLoggerFactory(LoggerFactory loggerFactory)
Description copied from interface:ConfigSets the LoggerFactory to use.- Specified by:
setLoggerFactoryin interfaceConfig
-
isVerifyHostKeyCertificates
public boolean isVerifyHostKeyCertificates()
Description copied from interface:ConfigReturns true if host key certificates should be verified while connecting to the server. It is recommended to verify them, but can cause connection failures in cases when previous versions of the library could have managed to connect.- Specified by:
isVerifyHostKeyCertificatesin interfaceConfig
-
setVerifyHostKeyCertificates
public void setVerifyHostKeyCertificates(boolean value)
Description copied from interface:ConfigSets whether the SSH client should verify host key certificates or not. SeeConfig.isVerifyHostKeyCertificates().- Specified by:
setVerifyHostKeyCertificatesin interfaceConfig
-
prioritizeSshRsaKeyAlgorithm
public void prioritizeSshRsaKeyAlgorithm()
Modern servers neglect the key algorithm ssh-rsa. OpenSSH 8.8 even dropped its support by default in favour of rsa-sha2-*. However, there are legacy servers like Apache SSHD that don't support the newer replacements for ssh-rsa. If ssh-rsa factory is ingetKeyAlgorithms(), this methods makes ssh-rsa key algorithm more preferred than any of rsa-sha2-*. Otherwise, nothing happens.
-
-