Class SshConfigFileReader

java.lang.Object
org.apache.sshd.common.config.SshConfigFileReader

public final class SshConfigFileReader extends Object
Reads and interprets some useful configurations from an OpenSSH configuration file.
Author:
Apache MINA SSHD Project
See Also:
  • Method Details

    • getCiphers

      public static org.apache.sshd.common.cipher.BuiltinCiphers.ParseResult getCiphers(org.apache.sshd.common.PropertyResolver props)
      Parameters:
      props - The PropertyResolver - ignored if null/empty
      Returns:
      A ParseResult of all the NamedFactory-ies whose name appears in the string and represent a built-in cipher. Any unknown name is ignored. The order of the returned result is the same as the original order - bar the unknown ciphers. Note: it is up to caller to ensure that the lists do not contain duplicates
      See Also:
      • CIPHERS_CONFIG_PROP
      • BuiltinCiphers.parseCiphersList(String)
    • getMacs

      public static org.apache.sshd.common.mac.BuiltinMacs.ParseResult getMacs(org.apache.sshd.common.PropertyResolver props)
      Parameters:
      props - The PropertyResolver - ignored if null/empty
      Returns:
      A ParseResult of all the NamedFactory-ies whose name appears in the string and represent a built-in MAC. Any unknown name is ignored. The order of the returned result is the same as the original order - bar the unknown MACs. Note: it is up to caller to ensure that the list does not contain duplicates
      See Also:
      • MACS_CONFIG_PROP
      • BuiltinMacs.parseMacsList(String)
    • getSignatures

      public static org.apache.sshd.common.signature.BuiltinSignatures.ParseResult getSignatures(org.apache.sshd.common.PropertyResolver props)
      Parameters:
      props - The PropertyResolver - ignored if null/empty
      Returns:
      A ParseResult of all the NamedFactory whose name appears in the string and represent a built-in signature. Any unknown name is ignored. The order of the returned result is the same as the original order - bar the unknown signatures. Note: it is up to caller to ensure that the list does not contain duplicates
      See Also:
      • HOST_KEY_ALGORITHMS_CONFIG_PROP
      • BuiltinSignatures.parseSignatureList(String)
    • getKexFactories

      public static BuiltinDHFactories.ParseResult getKexFactories(org.apache.sshd.common.PropertyResolver props)
      Parameters:
      props - The PropertyResolver - ignored if null/empty
      Returns:
      A ParseResult of all the DHFactory-ies whose name appears in the string and represent a built-in value. Any unknown name is ignored. The order of the returned result is the same as the original order - bar the unknown ones. Note: it is up to caller to ensure that the list does not contain duplicates
      See Also:
    • getCompression

      public static org.apache.sshd.common.compression.CompressionFactory getCompression(org.apache.sshd.common.PropertyResolver props)
      Parameters:
      props - The PropertyResolver - ignored if null/empty
      Returns:
      The matching NamedFactory for the configured value. null if no configuration or unknown name specified
      See Also:
      • COMPRESSION_PROP
    • configure

      public static <M extends AbstractFactoryManager> M configure(M manager, org.apache.sshd.common.PropertyResolver props, boolean lenient, boolean ignoreUnsupported)

      Configures an AbstractFactoryManager with the values read from some configuration. Currently it configures:

      • The Ciphers - via the ConfigFileReaderSupport.CIPHERS_CONFIG_PROP
      • The Macs - via the ConfigFileReaderSupport.MACS_CONFIG_PROP
      • The Signatures - via the ConfigFileReaderSupport.HOST_KEY_ALGORITHMS_CONFIG_PROP
      • The Compression - via the ConfigFileReaderSupport.COMPRESSION_PROP
      Type Parameters:
      M - The generic factory manager
      Parameters:
      manager - The AbstractFactoryManager to configure
      props - The PropertyResolver to use for configuration - Note: if any known configuration value has a default and does not appear in the properties, the default is used
      lenient - If true then any unknown configuration values are ignored. Otherwise an IllegalArgumentException is thrown
      ignoreUnsupported - filter out unsupported configuration values (e.g., ciphers, key exchanges, etc..). Note: if after filtering out all the unknown or unsupported values there is an empty configuration exception is thrown
      Returns:
      The configured manager
    • configureCiphers

      public static <M extends AbstractFactoryManager> M configureCiphers(M manager, org.apache.sshd.common.PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
    • configureCiphers

      public static <M extends AbstractFactoryManager> M configureCiphers(M manager, String value, boolean lenient, boolean ignoreUnsupported)
    • configureSignatures

      public static <M extends AbstractFactoryManager> M configureSignatures(M manager, org.apache.sshd.common.PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
    • configureSignatures

      public static <M extends AbstractFactoryManager> M configureSignatures(M manager, String value, boolean lenient, boolean ignoreUnsupported)
    • configureMacs

      public static <M extends AbstractFactoryManager> M configureMacs(M manager, org.apache.sshd.common.PropertyResolver resolver, boolean lenient, boolean ignoreUnsupported)
    • configureMacs

      public static <M extends AbstractFactoryManager> M configureMacs(M manager, String value, boolean lenient, boolean ignoreUnsupported)
    • configureKeyExchanges

      public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, org.apache.sshd.common.PropertyResolver props, boolean lenient, Function<? super DHFactory, ? extends KeyExchangeFactory> xformer, boolean ignoreUnsupported)
      Type Parameters:
      M - The generic factory manager
      Parameters:
      manager - The AbstractFactoryManager to set up (may not be null)
      props - The (non-null) PropertyResolver containing the configuration
      lenient - If true then any unknown/unsupported configuration values are ignored. Otherwise an IllegalArgumentException is thrown
      xformer - A Function to convert the configured DHFactory-ies to NamedFactory-ies of KeyExchange
      ignoreUnsupported - Filter out any un-supported configurations - Note: if after ignoring the unknown and un-supported values the result is an empty list of factories and exception is thrown
      Returns:
      The configured manager
      See Also:
      • KEX_ALGORITHMS_CONFIG_PROP
    • configureKeyExchanges

      public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, String value, boolean lenient, Function<? super DHFactory, ? extends KeyExchangeFactory> xformer, boolean ignoreUnsupported)
    • configureCompression

      public static <M extends AbstractFactoryManager> M configureCompression(M manager, org.apache.sshd.common.PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
      Configure the factory manager using one of the known CompressionConfigValues.
      Type Parameters:
      M - The generic factory manager
      Parameters:
      manager - The AbstractFactoryManager to configure
      props - The configuration Properties
      lenient - If true and an unknown value is provided then it is ignored
      ignoreUnsupported - If false then check if the compression is currently supported before setting it
      Returns:
      The configured manager - Note: if the result of filtering due to lenient mode or ignored unsupported value is empty then no factories are set
    • configureCompression

      public static <M extends AbstractFactoryManager> M configureCompression(M manager, String value, boolean lenient, boolean ignoreUnsupported)