This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mina-sshd.git
The following commit(s) were added to refs/heads/master by this push: new 4f4a752 [SSHD-1039] Fix support for some basic options in ssh/sshd cli 4f4a752 is described below commit 4f4a75297878a9dfb335138ebf65c205e46b160c Author: Guillaume Nodet <gno...@gmail.com> AuthorDate: Tue Jul 21 11:48:49 2020 +0200 [SSHD-1039] Fix support for some basic options in ssh/sshd cli --- CHANGES.md | 3 +- .../sshd/cli/client/SshClientCliSupport.java | 12 +- .../org/apache/sshd/cli/server/SshServerMain.java | 8 +- .../common/config/ConfigFileReaderSupport.java | 26 ---- .../client/config/SshClientConfigFileReader.java | 3 +- .../sshd/common/config/SshConfigFileReader.java | 132 +++++++++++---------- .../server/config/SshServerConfigFileReader.java | 3 +- .../common/config/SshConfigFileReaderTest.java | 32 +---- 8 files changed, 82 insertions(+), 137 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e1a255b..6f08d43 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,4 +19,5 @@ ## Behavioral changes and enhancements -* [SSHD-1033](https://issues.apache.org/jira/browse/SSHD-1033) Fix simultaneous usage of dynamic and local port forwarding. \ No newline at end of file +* [SSHD-1033](https://issues.apache.org/jira/browse/SSHD-1033) Fix simultaneous usage of dynamic and local port forwarding. +* [SSHD-1039](https://issues.apache.org/jira/browse/SSHD-1039) Fix support for some basic options in ssh/sshd cli. diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java index 7a04074..c7ab0e3 100644 --- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java +++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshClientCliSupport.java @@ -28,7 +28,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -71,6 +70,7 @@ import org.apache.sshd.common.compression.BuiltinCompressions; import org.apache.sshd.common.compression.Compression; import org.apache.sshd.common.config.CompressionConfigValue; import org.apache.sshd.common.config.ConfigFileReaderSupport; +import org.apache.sshd.common.config.SshConfigFileReader; import org.apache.sshd.common.config.keys.BuiltinIdentities; import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.config.keys.PublicKeyEntry; @@ -176,13 +176,7 @@ public abstract class SshClientCliSupport extends CliSupport { Path idFile = resolveIdentityFile(argVal); identities.add(idFile); } else if ("-C".equals(argName)) { - compressions = setupCompressions(argName, - GenericUtils.join( - Arrays.asList( - BuiltinCompressions.Constants.ZLIB, - BuiltinCompressions.Constants.DELAYED_ZLIB), - ','), - compressions, stderr); + compressions = setupCompressions(argName, argVal, compressions, stderr); if (GenericUtils.isEmpty(compressions)) { error = true; break; @@ -392,6 +386,8 @@ public abstract class SshClientCliSupport extends CliSupport { PrintStream stdout, PrintStream stderr, String... args) { SshClient client = setupIoServiceFactory( SshClient.setUpDefaultClient(), resolver, level, stdout, stderr, args); + SshConfigFileReader.configureKeyExchanges(client, resolver, true, ClientBuilder.DH2KEX, true); + SshConfigFileReader.configureSignatures(client, resolver, true, true); SshClientConfigFileReader.setupClientHeartbeat(client, resolver); return client; } diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java index a6e6e51..07f38a9 100644 --- a/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java +++ b/sshd-cli/src/main/java/org/apache/sshd/cli/server/SshServerMain.java @@ -33,7 +33,6 @@ import org.apache.sshd.common.NamedResource; import org.apache.sshd.common.PropertyResolver; import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.config.ConfigFileReaderSupport; -import org.apache.sshd.common.config.SshConfigFileReader; import org.apache.sshd.common.keyprovider.FileHostKeyCertificateProvider; import org.apache.sshd.common.keyprovider.HostKeyCertificateProvider; import org.apache.sshd.common.keyprovider.KeyPairProvider; @@ -179,7 +178,7 @@ public class SshServerMain extends SshServerCliSupport { Map<String, Object> props = sshd.getProperties(); props.putAll(options); - SshServerConfigFileReader.setupServerHeartbeat(sshd, resolver); + SshServerConfigFileReader.configure(sshd, resolver, true, true); KeyPairProvider hostKeyProvider = resolveServerKeys(System.err, hostKeyType, hostKeySize, keyFiles); sshd.setKeyPairProvider(hostKeyProvider); if (GenericUtils.isNotEmpty(certFiles)) { @@ -191,11 +190,6 @@ public class SshServerMain extends SshServerCliSupport { setupServerBanner(sshd, resolver); sshd.setPort(port); - String macsOverride = resolver.getString(ConfigFileReaderSupport.MACS_CONFIG_PROP); - if (GenericUtils.isNotEmpty(macsOverride)) { - SshConfigFileReader.configureMacs(sshd, macsOverride, true, true); - } - ShellFactory shellFactory = resolveShellFactory(System.err, resolver); if (shellFactory != null) { System.out.append("Using shell=").println(shellFactory.getClass().getName()); diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java b/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java index cd794c5..9f9ebdf 100644 --- a/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java +++ b/sshd-common/src/main/java/org/apache/sshd/common/config/ConfigFileReaderSupport.java @@ -30,15 +30,10 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.OpenOption; import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; import java.util.Properties; import java.util.concurrent.TimeUnit; import org.apache.sshd.common.PropertyResolverUtils; -import org.apache.sshd.common.auth.UserAuthMethodFactory; -import org.apache.sshd.common.keyprovider.KeyPairProvider; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.io.NoCloseInputStream; import org.apache.sshd.common.util.io.NoCloseReader; @@ -70,12 +65,6 @@ public final class ConfigFileReaderSupport { public static final boolean DEFAULT_KBD_INTERACTIVE_AUTH_VALUE = parseBooleanValue(DEFAULT_KBD_INTERACTIVE_AUTH); public static final String PREFERRED_AUTHS_CONFIG_PROP = "PreferredAuthentications"; - public static final List<String> DEFAULT_PREFERRED_AUTHS = Collections.unmodifiableList( - Arrays.asList( - UserAuthMethodFactory.PUBLIC_KEY, - UserAuthMethodFactory.KB_INTERACTIVE, - UserAuthMethodFactory.PASSWORD)); - public static final String DEFAULT_PREFERRED_AUTHS_VALUE = GenericUtils.join(DEFAULT_PREFERRED_AUTHS, ','); public static final String LISTEN_ADDRESS_CONFIG_PROP = "ListenAddress"; public static final String DEFAULT_BIND_ADDRESS = SshdSocketAddress.IPV4_ANYADDR; @@ -96,27 +85,12 @@ public final class ConfigFileReaderSupport { public static final long DEFAULT_REKEY_TIME_LIMIT = TimeUnit.HOURS.toMillis(1L); // see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html public static final String CIPHERS_CONFIG_PROP = "Ciphers"; - public static final String DEFAULT_CIPHERS = "aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc" - + ",blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour"; // see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html public static final String MACS_CONFIG_PROP = "MACs"; - public static final String DEFAULT_MACS = "hmac-md5,hmac-sha1,umac...@openssh.com,hmac-ripemd160,hmac-sha1-96" - + ",hmac-md5-96,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96"; // see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html public static final String KEX_ALGORITHMS_CONFIG_PROP = "KexAlgorithms"; - public static final String DEFAULT_KEX_ALGORITHMS = "ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521" - + "," - + "diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1" - // RFC-8268 groups - + "," + "diffie-hellman-group18-sha512,diffie-hellman-group17-sha512" - + "," + "diffie-hellman-group16-sha512,diffie-hellman-group15-sha512" - + "," + "diffie-hellman-group14-sha256" - // Legacy groups - + "," + "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1"; // see http://linux.die.net/man/5/ssh_config public static final String HOST_KEY_ALGORITHMS_CONFIG_PROP = "HostKeyAlgorithms"; - // see https://tools.ietf.org/html/rfc5656 - public static final String DEFAULT_HOST_KEY_ALGORITHMS = KeyPairProvider.SSH_RSA + "," + KeyPairProvider.SSH_DSS; // see http://manpages.ubuntu.com/manpages/precise/en/man5/sshd_config.5.html public static final String LOG_LEVEL_CONFIG_PROP = "LogLevel"; public static final LogLevelValue DEFAULT_LOG_LEVEL = LogLevelValue.INFO; diff --git a/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java index f93a2e9..742cda4 100644 --- a/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java +++ b/sshd-core/src/main/java/org/apache/sshd/client/config/SshClientConfigFileReader.java @@ -28,7 +28,6 @@ import org.apache.sshd.common.Property; import org.apache.sshd.common.PropertyResolver; import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.config.SshConfigFileReader; -import org.apache.sshd.common.helpers.AbstractFactoryManager; import org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.core.CoreModuleProperties; @@ -89,7 +88,7 @@ public final class SshClientConfigFileReader { public static <C extends SshClient> C configure( C client, PropertyResolver props, boolean lenient, boolean ignoreUnsupported) { - SshConfigFileReader.configure((AbstractFactoryManager) client, props, lenient, ignoreUnsupported); + SshConfigFileReader.configure(client, props, lenient, ignoreUnsupported); SshConfigFileReader.configureKeyExchanges(client, props, lenient, ClientBuilder.DH2KEX, ignoreUnsupported); setupClientHeartbeat(client, props); return client; diff --git a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java index 4be1aaf..6aa3b52 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/config/SshConfigFileReader.java @@ -162,8 +162,7 @@ public final class SshConfigFileReader { M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(props, "No properties to configure"); return configureCiphers(manager, - props.getStringProperty( - ConfigFileReaderSupport.CIPHERS_CONFIG_PROP, ConfigFileReaderSupport.DEFAULT_CIPHERS), + props.getString(ConfigFileReaderSupport.CIPHERS_CONFIG_PROP), lenient, ignoreUnsupported); } @@ -171,14 +170,17 @@ public final class SshConfigFileReader { M manager, String value, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(manager, "No manager to configure"); - BuiltinCiphers.ParseResult result = BuiltinCiphers.parseCiphersList(value); - Collection<String> unsupported = result.getUnsupportedFactories(); - ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), - "Unsupported cipher(s) (%s) in %s", unsupported, value); + if (!GenericUtils.isEmpty(value)) { + BuiltinCiphers.ParseResult result = BuiltinCiphers.parseCiphersList(value); + Collection<String> unsupported = result.getUnsupportedFactories(); + ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), + "Unsupported cipher(s) (%s) in %s", unsupported, value); - List<NamedFactory<Cipher>> factories = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); - manager.setCipherFactories( - ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/unsupported ciphers(s): %s", value)); + List<NamedFactory<Cipher>> factories + = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); + manager.setCipherFactories( + ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/unsupported ciphers(s): %s", value)); + } return manager; } @@ -186,9 +188,7 @@ public final class SshConfigFileReader { M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(props, "No properties to configure"); return configureSignatures(manager, - props.getStringProperty( - ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP, - ConfigFileReaderSupport.DEFAULT_HOST_KEY_ALGORITHMS), + props.getString(ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP), lenient, ignoreUnsupported); } @@ -196,14 +196,17 @@ public final class SshConfigFileReader { M manager, String value, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(manager, "No manager to configure"); - BuiltinSignatures.ParseResult result = BuiltinSignatures.parseSignatureList(value); - Collection<String> unsupported = result.getUnsupportedFactories(); - ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), - "Unsupported signatures (%s) in %s", unsupported, value); + if (!GenericUtils.isEmpty(value)) { + BuiltinSignatures.ParseResult result = BuiltinSignatures.parseSignatureList(value); + Collection<String> unsupported = result.getUnsupportedFactories(); + ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), + "Unsupported signatures (%s) in %s", unsupported, value); - List<NamedFactory<Signature>> factories = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); - manager.setSignatureFactories( - ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported signatures: %s", value)); + List<NamedFactory<Signature>> factories + = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); + manager.setSignatureFactories( + ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported signatures: %s", value)); + } return manager; } @@ -211,8 +214,7 @@ public final class SshConfigFileReader { M manager, PropertyResolver resolver, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(resolver, "No properties to configure"); return configureMacs(manager, - resolver.getStringProperty( - ConfigFileReaderSupport.MACS_CONFIG_PROP, ConfigFileReaderSupport.DEFAULT_MACS), + resolver.getString(ConfigFileReaderSupport.MACS_CONFIG_PROP), lenient, ignoreUnsupported); } @@ -220,14 +222,16 @@ public final class SshConfigFileReader { M manager, String value, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(manager, "No manager to configure"); - BuiltinMacs.ParseResult result = BuiltinMacs.parseMacsList(value); - Collection<String> unsupported = result.getUnsupportedFactories(); - ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), - "Unsupported MAC(s) (%s) in %s", unsupported, value); + if (!GenericUtils.isEmpty(value)) { + BuiltinMacs.ParseResult result = BuiltinMacs.parseMacsList(value); + Collection<String> unsupported = result.getUnsupportedFactories(); + ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), + "Unsupported MAC(s) (%s) in %s", unsupported, value); - List<NamedFactory<Mac>> factories = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); - manager.setMacFactories( - ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported MAC(s): %s", value)); + List<NamedFactory<Mac>> factories = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); + manager.setMacFactories( + ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported MAC(s): %s", value)); + } return manager; } @@ -251,8 +255,7 @@ public final class SshConfigFileReader { Function<? super DHFactory, ? extends KeyExchangeFactory> xformer, boolean ignoreUnsupported) { Objects.requireNonNull(props, "No properties to configure"); return configureKeyExchanges(manager, - props.getStringProperty( - ConfigFileReaderSupport.KEX_ALGORITHMS_CONFIG_PROP, ConfigFileReaderSupport.DEFAULT_KEX_ALGORITHMS), + props.getString(ConfigFileReaderSupport.KEX_ALGORITHMS_CONFIG_PROP), lenient, xformer, ignoreUnsupported); } @@ -262,15 +265,17 @@ public final class SshConfigFileReader { Objects.requireNonNull(manager, "No manager to configure"); Objects.requireNonNull(xformer, "No DHFactory transformer"); - BuiltinDHFactories.ParseResult result = BuiltinDHFactories.parseDHFactoriesList(value); - Collection<String> unsupported = result.getUnsupportedFactories(); - ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), - "Unsupported KEX(s) (%s) in %s", unsupported, value); + if (!GenericUtils.isEmpty(value)) { + BuiltinDHFactories.ParseResult result = BuiltinDHFactories.parseDHFactoriesList(value); + Collection<String> unsupported = result.getUnsupportedFactories(); + ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), + "Unsupported KEX(s) (%s) in %s", unsupported, value); - List<KeyExchangeFactory> factories - = NamedFactory.setUpTransformedFactories(ignoreUnsupported, result.getParsedFactories(), xformer); - manager.setKeyExchangeFactories( - ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported KEXS(s): %s", value)); + List<KeyExchangeFactory> factories + = NamedFactory.setUpTransformedFactories(ignoreUnsupported, result.getParsedFactories(), xformer); + manager.setKeyExchangeFactories( + ValidateUtils.checkNotNullAndNotEmpty(factories, "No known/supported KEXS(s): %s", value)); + } return manager; } @@ -290,14 +295,14 @@ public final class SshConfigFileReader { Objects.requireNonNull(manager, "No manager to configure"); Objects.requireNonNull(props, "No properties to configure"); - String value = props.getStringProperty(ConfigFileReaderSupport.COMPRESSION_PROP, - ConfigFileReaderSupport.DEFAULT_COMPRESSION); - CompressionFactory factory = CompressionConfigValue.fromName(value); - ValidateUtils.checkTrue(lenient || (factory != null), "Unsupported compression value: %s", value); - if ((factory != null) && factory.isSupported()) { - manager.setCompressionFactories(Collections.singletonList(factory)); + String value = props.getString(ConfigFileReaderSupport.COMPRESSION_PROP); + if (!GenericUtils.isEmpty(value)) { + CompressionFactory factory = CompressionConfigValue.fromName(value); + ValidateUtils.checkTrue(lenient || (factory != null), "Unsupported compression value: %s", value); + if ((factory != null) && factory.isSupported()) { + manager.setCompressionFactories(Collections.singletonList(factory)); + } } - return manager; } @@ -306,26 +311,27 @@ public final class SshConfigFileReader { M manager, String value, boolean lenient, boolean ignoreUnsupported) { Objects.requireNonNull(manager, "No manager to configure"); - CompressionFactory factory = CompressionConfigValue.fromName(value); - if (factory != null) { - // SSH can work without compression - if (ignoreUnsupported || factory.isSupported()) { - manager.setCompressionFactories(Collections.singletonList(factory)); - } - } else { - BuiltinCompressions.ParseResult result = BuiltinCompressions.parseCompressionsList(value); - Collection<String> unsupported = result.getUnsupportedFactories(); - ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), "Unsupported compressions(s) (%s) in %s", - unsupported, value); - - List<NamedFactory<Compression>> factories - = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); - // SSH can work without compression - if (GenericUtils.size(factories) > 0) { - manager.setCompressionFactories(factories); + if (!GenericUtils.isEmpty(value)) { + CompressionFactory factory = CompressionConfigValue.fromName(value); + if (factory != null) { + // SSH can work without compression + if (ignoreUnsupported || factory.isSupported()) { + manager.setCompressionFactories(Collections.singletonList(factory)); + } + } else { + BuiltinCompressions.ParseResult result = BuiltinCompressions.parseCompressionsList(value); + Collection<String> unsupported = result.getUnsupportedFactories(); + ValidateUtils.checkTrue(lenient || GenericUtils.isEmpty(unsupported), "Unsupported compressions(s) (%s) in %s", + unsupported, value); + + List<NamedFactory<Compression>> factories + = BuiltinFactory.setUpFactories(ignoreUnsupported, result.getParsedFactories()); + // SSH can work without compression + if (GenericUtils.size(factories) > 0) { + manager.setCompressionFactories(factories); + } } } - return manager; } } diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java b/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java index 1efbc40..9eb79aa 100644 --- a/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java +++ b/sshd-core/src/main/java/org/apache/sshd/server/config/SshServerConfigFileReader.java @@ -27,7 +27,6 @@ import org.apache.sshd.common.PropertyResolver; import org.apache.sshd.common.PropertyResolverUtils; import org.apache.sshd.common.config.ConfigFileReaderSupport; import org.apache.sshd.common.config.SshConfigFileReader; -import org.apache.sshd.common.helpers.AbstractFactoryManager; import org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ValidateUtils; @@ -104,7 +103,7 @@ public final class SshServerConfigFileReader { public static <S extends SshServer> S configure( S server, PropertyResolver props, boolean lenient, boolean ignoreUnsupported) { - SshConfigFileReader.configure((AbstractFactoryManager) server, props, lenient, ignoreUnsupported); + SshConfigFileReader.configure(server, props, lenient, ignoreUnsupported); SshConfigFileReader.configureKeyExchanges(server, props, lenient, ServerBuilder.DH2KEX, ignoreUnsupported); setupServerHeartbeat(server, props); return server; diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java index fec9e6f..9b529d9 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java @@ -93,12 +93,6 @@ public class SshConfigFileReaderTest extends BaseTestSupport { } @Test - public void testKnownDefaultCipherFactoriesList() { - testKnownDefaultFactoriesList(ConfigFileReaderSupport.DEFAULT_CIPHERS, BuiltinCiphers::fromFactoryName, - GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, "cast128-cbc", "arcfour")); - } - - @Test public void testParseMacsList() { List<? extends NamedResource> expected = BaseBuilder.DEFAULT_MAC_PREFERENCE; Properties props = initNamedResourceProperties(ConfigFileReaderSupport.MACS_CONFIG_PROP, expected); @@ -107,13 +101,6 @@ public class SshConfigFileReaderTest extends BaseTestSupport { } @Test - public void testKnownDefaultMacFactoriesList() { - testKnownDefaultFactoriesList(ConfigFileReaderSupport.DEFAULT_MACS, BuiltinMacs::fromFactoryName, - GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, "umac...@openssh.com", "hmac-ripemd160", - "hmac-sha2-256-96", "hmac-sha2-512-96")); - } - - @Test public void testParseSignaturesList() { List<? extends NamedResource> expected = ClientBuilder.DEFAULT_SIGNATURE_PREFERENCE; Properties props = initNamedResourceProperties(ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP, expected); @@ -123,11 +110,6 @@ public class SshConfigFileReaderTest extends BaseTestSupport { } @Test - public void testKnownDefaultSignatureFactoriesList() { - testKnownDefaultFactoriesList(ConfigFileReaderSupport.DEFAULT_HOST_KEY_ALGORITHMS, BuiltinSignatures::fromFactoryName); - } - - @Test public void testParseKexFactoriesList() { List<? extends NamedResource> expected = BaseBuilder.DEFAULT_KEX_PREFERENCE; Properties props = initNamedResourceProperties(ConfigFileReaderSupport.KEX_ALGORITHMS_CONFIG_PROP, expected); @@ -136,11 +118,6 @@ public class SshConfigFileReaderTest extends BaseTestSupport { testParsedFactoriesList(expected, result.getParsedFactories(), result.getUnsupportedFactories()); } - @Test - public void testKnownDefaultKexFactoriesList() { - testKnownDefaultFactoriesList(ConfigFileReaderSupport.DEFAULT_KEX_ALGORITHMS, BuiltinDHFactories::fromFactoryName); - } - private static void testKnownDefaultFactoriesList( String factories, Function<? super String, ? extends NamedResource> resolver) { testKnownDefaultFactoriesList(factories, resolver, Collections.emptySet()); @@ -294,7 +271,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport { private static <M extends FactoryManager> M validateFactoryManagerCiphers(M manager, Properties props) { return validateFactoryManagerCiphers(manager, - props.getProperty(ConfigFileReaderSupport.CIPHERS_CONFIG_PROP, ConfigFileReaderSupport.DEFAULT_CIPHERS)); + props.getProperty(ConfigFileReaderSupport.CIPHERS_CONFIG_PROP)); } private static <M extends FactoryManager> M validateFactoryManagerCiphers(M manager, String value) { @@ -305,8 +282,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport { private static <M extends FactoryManager> M validateFactoryManagerSignatures(M manager, Properties props) { return validateFactoryManagerSignatures(manager, - props.getProperty(ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP, - ConfigFileReaderSupport.DEFAULT_HOST_KEY_ALGORITHMS)); + props.getProperty(ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP)); } private static <M extends FactoryManager> M validateFactoryManagerSignatures(M manager, String value) { @@ -317,7 +293,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport { private static <M extends FactoryManager> M validateFactoryManagerMacs(M manager, Properties props) { return validateFactoryManagerMacs(manager, - props.getProperty(ConfigFileReaderSupport.MACS_CONFIG_PROP, ConfigFileReaderSupport.DEFAULT_MACS)); + props.getProperty(ConfigFileReaderSupport.MACS_CONFIG_PROP)); } private static <M extends FactoryManager> M validateFactoryManagerMacs(M manager, String value) { @@ -329,7 +305,7 @@ public class SshConfigFileReaderTest extends BaseTestSupport { private static < M extends FactoryManager> M validateFactoryManagerCompressions(M manager, Properties props, boolean lenient) { return validateFactoryManagerCompressions(manager, - props.getProperty(ConfigFileReaderSupport.COMPRESSION_PROP, ConfigFileReaderSupport.DEFAULT_COMPRESSION), + props.getProperty(ConfigFileReaderSupport.COMPRESSION_PROP), lenient); }