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
.KeepAliveProvider
getKeepAliveProvider()
java.util.List<Factory.Named<KeyAlgorithm>>
getKeyAlgorithms()
Retrieve the list of named factories forKeyAlgorithm
java.util.List<Factory.Named<KeyExchange>>
getKeyExchangeFactories()
Retrieve the list of named factories forKeyExchange
.LoggerFactory
getLoggerFactory()
java.util.List<Factory.Named<MAC>>
getMACFactories()
Retrieve the list of named factories forMAC
.Factory<Random>
getRandomFactory()
Retrieve theRandom
factory.java.lang.String
getVersion()
Returns the software version information for identification during SSH connection initialization.boolean
isVerifyHostKeyCertificates()
Returns true if host key certificates should be verified while connecting to the server.boolean
isWaitForServerIdentBeforeSendingClientIdent()
Gets whether the client should first wait for a received server ident, before sending the client ident.void
prioritizeSshRsaKeyAlgorithm()
Modern servers neglect the key algorithm ssh-rsa.void
setCipherFactories(java.util.List<Factory.Named<Cipher>> cipherFactories)
Set the named factories forCipher
.void
setCipherFactories(Factory.Named<Cipher>... cipherFactories)
void
setCompressionFactories(java.util.List<Factory.Named<Compression>> compressionFactories)
Set the named factories forCompression
.void
setCompressionFactories(Factory.Named<Compression>... compressionFactories)
void
setFileKeyProviderFactories(java.util.List<Factory.Named<FileKeyProvider>> fileKeyProviderFactories)
Set the named factories forFileKeyProvider
.void
setFileKeyProviderFactories(Factory.Named<FileKeyProvider>... fileKeyProviderFactories)
void
setKeepAliveProvider(KeepAliveProvider keepAliveProvider)
Set the provider that provides the keep-alive implementation.void
setKeyAlgorithms(java.util.List<Factory.Named<KeyAlgorithm>> keyAlgorithms)
Set the named factories forKeyAlgorithm
.void
setKeyExchangeFactories(java.util.List<Factory.Named<KeyExchange>> kexFactories)
Set the named factories forKeyExchange
.void
setKeyExchangeFactories(Factory.Named<KeyExchange>... kexFactories)
void
setLoggerFactory(LoggerFactory loggerFactory)
Sets the LoggerFactory to use.void
setMACFactories(java.util.List<Factory.Named<MAC>> macFactories)
Set the named factories forMAC
.void
setMACFactories(Factory.Named<MAC>... macFactories)
void
setRandomFactory(Factory<Random> randomFactory)
Set the factory forRandom
.void
setVerifyHostKeyCertificates(boolean value)
Sets whether the SSH client should verify host key certificates or not.void
setVersion(java.lang.String version)
Set the software version information for identification during SSH connection initialization.void
setWaitForServerIdentBeforeSendingClientIdent(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:Config
Retrieve the list of named factories forCipher
.- Specified by:
getCipherFactories
in interfaceConfig
- Returns:
- a list of named
Cipher
factories
-
getCompressionFactories
public java.util.List<Factory.Named<Compression>> getCompressionFactories()
Description copied from interface:Config
Retrieve the list of named factories forCompression
.- Specified by:
getCompressionFactories
in interfaceConfig
- Returns:
- a list of named
Compression
factories
-
getFileKeyProviderFactories
public java.util.List<Factory.Named<FileKeyProvider>> getFileKeyProviderFactories()
Description copied from interface:Config
Retrieve the list of named factories forFileKeyProvider
.- Specified by:
getFileKeyProviderFactories
in interfaceConfig
- Returns:
- a list of named
FileKeyProvider
factories
-
getKeyExchangeFactories
public java.util.List<Factory.Named<KeyExchange>> getKeyExchangeFactories()
Description copied from interface:Config
Retrieve the list of named factories forKeyExchange
.- Specified by:
getKeyExchangeFactories
in interfaceConfig
- Returns:
- a list of named
KeyExchange
factories
-
getMACFactories
public java.util.List<Factory.Named<MAC>> getMACFactories()
Description copied from interface:Config
Retrieve the list of named factories forMAC
.- Specified by:
getMACFactories
in interfaceConfig
- Returns:
- a list of named
MAC
factories
-
getRandomFactory
public Factory<Random> getRandomFactory()
Description copied from interface:Config
Retrieve theRandom
factory.- Specified by:
getRandomFactory
in interfaceConfig
- Returns:
- the
Random
factory
-
getVersion
public java.lang.String getVersion()
Description copied from interface:Config
Returns the software version information for identification during SSH connection initialization. For example,"NET_3_0"
.- Specified by:
getVersion
in interfaceConfig
-
setCipherFactories
public void setCipherFactories(Factory.Named<Cipher>... cipherFactories)
-
setCipherFactories
public void setCipherFactories(java.util.List<Factory.Named<Cipher>> cipherFactories)
Description copied from interface:Config
Set the named factories forCipher
.- Specified by:
setCipherFactories
in 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:Config
Set the named factories forCompression
.- Specified by:
setCompressionFactories
in 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:Config
Set the named factories forFileKeyProvider
.- Specified by:
setFileKeyProviderFactories
in 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:Config
Set the named factories forKeyExchange
.- Specified by:
setKeyExchangeFactories
in 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:Config
Set the named factories forMAC
.- Specified by:
setMACFactories
in interfaceConfig
- Parameters:
macFactories
- a list of named factories
-
setRandomFactory
public void setRandomFactory(Factory<Random> randomFactory)
Description copied from interface:Config
Set the factory forRandom
.- Specified by:
setRandomFactory
in interfaceConfig
- Parameters:
randomFactory
- the factory
-
setVersion
public void setVersion(java.lang.String version)
Description copied from interface:Config
Set the software version information for identification during SSH connection initialization. For example,"SSHJ_0_1"
.- Specified by:
setVersion
in interfaceConfig
- Parameters:
version
- software version info
-
getKeepAliveProvider
public KeepAliveProvider getKeepAliveProvider()
- Specified by:
getKeepAliveProvider
in interfaceConfig
- Returns:
- The provider that creates the keep-alive implementation of choice.
-
setKeepAliveProvider
public void setKeepAliveProvider(KeepAliveProvider keepAliveProvider)
Description copied from interface:Config
Set the provider that provides the keep-alive implementation.- Specified by:
setKeepAliveProvider
in interfaceConfig
- Parameters:
keepAliveProvider
- keep-alive provider
-
isWaitForServerIdentBeforeSendingClientIdent
public boolean isWaitForServerIdentBeforeSendingClientIdent()
Description copied from interface:Config
Gets 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:
isWaitForServerIdentBeforeSendingClientIdent
in interfaceConfig
- Returns:
- Whether to first wait for the server ident.
-
setWaitForServerIdentBeforeSendingClientIdent
public void setWaitForServerIdentBeforeSendingClientIdent(boolean waitForServerIdentBeforeSendingClientIdent)
Description copied from interface:Config
Sets 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:
setWaitForServerIdentBeforeSendingClientIdent
in interfaceConfig
- Parameters:
waitForServerIdentBeforeSendingClientIdent
- Whether to wait for the server ident.
-
getKeyAlgorithms
public java.util.List<Factory.Named<KeyAlgorithm>> getKeyAlgorithms()
Description copied from interface:Config
Retrieve the list of named factories forKeyAlgorithm
- Specified by:
getKeyAlgorithms
in interfaceConfig
- Returns:
- a list of named
KeyAlgorithm
factories
-
setKeyAlgorithms
public void setKeyAlgorithms(java.util.List<Factory.Named<KeyAlgorithm>> keyAlgorithms)
Description copied from interface:Config
Set the named factories forKeyAlgorithm
.- Specified by:
setKeyAlgorithms
in interfaceConfig
- Parameters:
keyAlgorithms
- a list of named factories
-
getLoggerFactory
public LoggerFactory getLoggerFactory()
- Specified by:
getLoggerFactory
in interfaceConfig
- Returns:
- The LoggerFactory the SSHClient will use.
-
setLoggerFactory
public void setLoggerFactory(LoggerFactory loggerFactory)
Description copied from interface:Config
Sets the LoggerFactory to use.- Specified by:
setLoggerFactory
in interfaceConfig
-
isVerifyHostKeyCertificates
public boolean isVerifyHostKeyCertificates()
Description copied from interface:Config
Returns 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:
isVerifyHostKeyCertificates
in interfaceConfig
-
setVerifyHostKeyCertificates
public void setVerifyHostKeyCertificates(boolean value)
Description copied from interface:Config
Sets whether the SSH client should verify host key certificates or not. SeeConfig.isVerifyHostKeyCertificates()
.- Specified by:
setVerifyHostKeyCertificates
in 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.
-
-