Top Description Constructors Methods
org.apache.sshd.common.config

public final Class SshConfigFileReader

extends Object
Class Inheritance
Imports
java.util.Collection, .Collections, .List, .Objects, .Properties, java.util.function.Function, org.apache.sshd.common.BuiltinFactory, .NamedFactory, .PropertyResolver, org.apache.sshd.common.cipher.BuiltinCiphers, .Cipher, org.apache.sshd.common.compression.BuiltinCompressions, .Compression, .CompressionFactory, org.apache.sshd.common.helpers.AbstractFactoryManager, org.apache.sshd.common.kex.BuiltinDHFactories, .DHFactory, .KeyExchange, .KeyExchangeFactory, org.apache.sshd.common.mac.BuiltinMacs, .Mac, org.apache.sshd.common.signature.BuiltinSignatures, .Signature, org.apache.sshd.common.util.GenericUtils, .ValidateUtils

Reads and interprets some useful configurations from an OpenSSH configuration file.
Author
Apache MINA SSHD Project
See Also
ssh_config(5)

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
The generic factory manager
M extends AbstractFactoryManager
>
M

Returns:

The configured manager
configure
(M
The AbstractFactoryManager to configure
manager
,
PropertyResolver
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
props
,
boolean
If true then any unknown configuration values are ignored. Otherwise an IllegalArgumentException is thrown
lenient
,
boolean
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

ignoreUnsupported
)

Configures an AbstractFactoryManager with the values read from some configuration.

public static <M extends AbstractFactoryManager> M
configureCiphers(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)

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

public static <
The generic factory manager
M extends AbstractFactoryManager
>
M

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
(M
The AbstractFactoryManager to configure
manager
,
PropertyResolver
The configuration Properties
props
,
boolean
If true and an unknown value is provided then it is ignored
lenient
,
boolean
If false then check if the compression is currently supported before setting it
ignoreUnsupported
)

Configure the factory manager using one of the known CompressionConfigValues.

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

public static <
The generic factory manager
M extends AbstractFactoryManager
>
M

Returns:

The configured manager
configureKeyExchanges
(M
The AbstractFactoryManager to set up (may not be null)
manager
,
PropertyResolver
The (non-null) PropertyResolver containing the configuration
props
,
boolean
If true then any unknown/unsupported configuration values are ignored. Otherwise an IllegalArgumentException is thrown
lenient
,
Function<? super DHFactory, ? extends KeyExchangeFactory>
A Function to convert the configured DHFactory-ies to NamedFactory-ies of KeyExchange
xformer
,
boolean
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
ignoreUnsupported
)

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

public static <M extends AbstractFactoryManager> M
configureMacs(M manager, PropertyResolver resolver, boolean lenient, boolean ignoreUnsupported)

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

public static <M extends AbstractFactoryManager> M
configureSignatures(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)

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

public static BuiltinCiphers.ParseResult

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

getCiphers
(PropertyResolver
The PropertyResolver - ignored if null/empty
props
)

public static CompressionFactory

Returns:

The matching NamedFactory for the configured value. null if no configuration or unknown name specified
getCompression
(PropertyResolver
The PropertyResolver - ignored if null/empty
props
)

public static BuiltinDHFactories.ParseResult

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

getKexFactories
(PropertyResolver
The PropertyResolver - ignored if null/empty
props
)

public static BuiltinMacs.ParseResult

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

getMacs
(PropertyResolver
The PropertyResolver - ignored if null/empty
props
)

public static BuiltinSignatures.ParseResult

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

getSignatures
(PropertyResolver
The PropertyResolver - ignored if null/empty
props
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SshConfigFileReaderback to summary
private SshConfigFileReader()

Method Detail

configureback to summary
public static <M extends AbstractFactoryManager> M configure(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)

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

Parameters
<M>
The generic factory manager
manager:M

The AbstractFactoryManager to configure

props:PropertyResolver

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:boolean

If true then any unknown configuration values are ignored. Otherwise an IllegalArgumentException is thrown

ignoreUnsupported:boolean

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:M

The configured manager

configureCiphersback to summary
public static <M extends AbstractFactoryManager> M configureCiphers(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
configureCiphersback to summary
public static <M extends AbstractFactoryManager> M configureCiphers(M manager, String value, boolean lenient, boolean ignoreUnsupported)
configureCompressionback to summary
public static <M extends AbstractFactoryManager> M configureCompression(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)

Configure the factory manager using one of the known CompressionConfigValues.

Parameters
<M>
The generic factory manager
manager:M

The AbstractFactoryManager to configure

props:PropertyResolver

The configuration Properties

lenient:boolean

If true and an unknown value is provided then it is ignored

ignoreUnsupported:boolean

If false then check if the compression is currently supported before setting it

Returns:M

The configured manager - Note: if the result of filtering due to lenient mode or ignored unsupported value is empty then no factories are set

configureCompressionback to summary
public static <M extends AbstractFactoryManager> M configureCompression(M manager, String value, boolean lenient, boolean ignoreUnsupported)
configureKeyExchangesback to summary
public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, PropertyResolver props, boolean lenient, Function<? super DHFactory, ? extends KeyExchangeFactory> xformer, boolean ignoreUnsupported)
Parameters
<M>
The generic factory manager
manager:M

The AbstractFactoryManager to set up (may not be null)

props:PropertyResolver

The (non-null) PropertyResolver containing the configuration

lenient:boolean

If true then any unknown/unsupported configuration values are ignored. Otherwise an IllegalArgumentException is thrown

xformer:Function<? super DHFactory, ? extends KeyExchangeFactory>

A Function to convert the configured DHFactory-ies to NamedFactory-ies of KeyExchange

ignoreUnsupported:boolean

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:M

The configured manager

See Also
KEX_ALGORITHMS_CONFIG_PROP
configureKeyExchangesback to summary
public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, String value, boolean lenient, Function<? super DHFactory, ? extends KeyExchangeFactory> xformer, boolean ignoreUnsupported)
configureMacsback to summary
public static <M extends AbstractFactoryManager> M configureMacs(M manager, PropertyResolver resolver, boolean lenient, boolean ignoreUnsupported)
configureMacsback to summary
public static <M extends AbstractFactoryManager> M configureMacs(M manager, String value, boolean lenient, boolean ignoreUnsupported)
configureSignaturesback to summary
public static <M extends AbstractFactoryManager> M configureSignatures(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
configureSignaturesback to summary
public static <M extends AbstractFactoryManager> M configureSignatures(M manager, String value, boolean lenient, boolean ignoreUnsupported)
getCiphersback to summary
public static BuiltinCiphers.ParseResult getCiphers(PropertyResolver props)
Parameters
props:PropertyResolver

The PropertyResolver - ignored if null/empty

Returns:BuiltinCiphers.ParseResult

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)
getCompressionback to summary
public static CompressionFactory getCompression(PropertyResolver props)
Parameters
props:PropertyResolver

The PropertyResolver - ignored if null/empty

Returns:CompressionFactory

The matching NamedFactory for the configured value. null if no configuration or unknown name specified

See Also
COMPRESSION_PROP
getKexFactoriesback to summary
public static BuiltinDHFactories.ParseResult getKexFactories(PropertyResolver props)
Parameters
props:PropertyResolver

The PropertyResolver - ignored if null/empty

Returns:BuiltinDHFactories.ParseResult

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
KEX_ALGORITHMS_CONFIG_PROP, BuiltinDHFactories#parseDHFactoriesList(String)
getMacsback to summary
public static BuiltinMacs.ParseResult getMacs(PropertyResolver props)
Parameters
props:PropertyResolver

The PropertyResolver - ignored if null/empty

Returns:BuiltinMacs.ParseResult

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)
getSignaturesback to summary
public static BuiltinSignatures.ParseResult getSignatures(PropertyResolver props)
Parameters
props:PropertyResolver

The PropertyResolver - ignored if null/empty

Returns:BuiltinSignatures.ParseResult

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)