public final class SshConfigFileReader
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
SshConfigFileReader() |
Modifier and Type | Method and Description |
---|---|
static <M extends AbstractFactoryManager> |
configure(M manager,
PropertyResolver props,
boolean lenient,
boolean ignoreUnsupported)
Configures an
AbstractFactoryManager with the values read from
some configuration. |
static <M extends AbstractFactoryManager> |
configureCiphers(M manager,
PropertyResolver props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureCiphers(M manager,
java.lang.String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureCompression(M manager,
PropertyResolver props,
boolean lenient,
boolean ignoreUnsupported)
Configure the factory manager using one of the known
CompressionConfigValue s. |
static <M extends AbstractFactoryManager> |
configureCompression(M manager,
java.lang.String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureKeyExchanges(M manager,
PropertyResolver props,
boolean lenient,
java.util.function.Function<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureKeyExchanges(M manager,
java.lang.String value,
boolean lenient,
java.util.function.Function<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureMacs(M manager,
PropertyResolver resolver,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureMacs(M manager,
java.lang.String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureSignatures(M manager,
PropertyResolver props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureSignatures(M manager,
java.lang.String value,
boolean lenient,
boolean ignoreUnsupported) |
static BuiltinCiphers.ParseResult |
getCiphers(PropertyResolver props) |
static CompressionFactory |
getCompression(PropertyResolver props) |
static BuiltinDHFactories.ParseResult |
getKexFactories(PropertyResolver props) |
static BuiltinMacs.ParseResult |
getMacs(PropertyResolver props) |
static BuiltinSignatures.ParseResult |
getSignatures(PropertyResolver props) |
static boolean |
parseBooleanValue(java.lang.String v) |
static java.util.Properties |
readConfigFile(java.io.BufferedReader rdr)
Reads the configuration file contents into a
Properties instance. |
static java.util.Properties |
readConfigFile(java.io.File file) |
static java.util.Properties |
readConfigFile(java.io.InputStream input,
boolean okToClose) |
static java.util.Properties |
readConfigFile(java.nio.file.Path path,
java.nio.file.OpenOption... options) |
static java.util.Properties |
readConfigFile(java.io.Reader reader,
boolean okToClose) |
static java.util.Properties |
readConfigFile(java.lang.String path) |
static java.util.Properties |
readConfigFile(java.net.URL url) |
static java.lang.String |
yesNoValueOf(boolean flag)
Returns a "yes" or "no" value based on the input
parameter
|
public static final char COMMENT_CHAR
public static final java.lang.String COMPRESSION_PROP
public static final java.lang.String DEFAULT_COMPRESSION
public static final java.lang.String MAX_SESSIONS_CONFIG_PROP
public static final int DEFAULT_MAX_SESSIONS
public static final java.lang.String PASSWORD_AUTH_CONFIG_PROP
public static final java.lang.String DEFAULT_PASSWORD_AUTH
public static final boolean DEFAULT_PASSWORD_AUTH_VALUE
public static final java.lang.String LISTEN_ADDRESS_CONFIG_PROP
public static final java.lang.String DEFAULT_BIND_ADDRESS
public static final java.lang.String PORT_CONFIG_PROP
public static final int DEFAULT_PORT
public static final java.lang.String KEEP_ALIVE_CONFIG_PROP
public static final boolean DEFAULT_KEEP_ALIVE
public static final java.lang.String USE_DNS_CONFIG_PROP
public static final boolean DEFAULT_USE_DNS
public static final java.lang.String PUBKEY_AUTH_CONFIG_PROP
public static final java.lang.String DEFAULT_PUBKEY_AUTH
public static final boolean DEFAULT_PUBKEY_AUTH_VALUE
public static final java.lang.String AUTH_KEYS_FILE_CONFIG_PROP
public static final java.lang.String MAX_AUTH_TRIES_CONFIG_PROP
public static final int DEFAULT_MAX_AUTH_TRIES
public static final java.lang.String MAX_STARTUPS_CONFIG_PROP
public static final int DEFAULT_MAX_STARTUPS
public static final java.lang.String LOGIN_GRACE_TIME_CONFIG_PROP
public static final long DEFAULT_LOGIN_GRACE_TIME
public static final java.lang.String KEY_REGENERATE_INTERVAL_CONFIG_PROP
public static final long DEFAULT_REKEY_TIME_LIMIT
public static final java.lang.String CIPHERS_CONFIG_PROP
public static final java.lang.String DEFAULT_CIPHERS
public static final java.lang.String MACS_CONFIG_PROP
public static final java.lang.String DEFAULT_MACS
public static final java.lang.String KEX_ALGORITHMS_CONFIG_PROP
public static final java.lang.String DEFAULT_KEX_ALGORITHMS
public static final java.lang.String HOST_KEY_ALGORITHMS_CONFIG_PROP
public static final java.lang.String DEFAULT_HOST_KEY_ALGORITHMS
public static final java.lang.String LOG_LEVEL_CONFIG_PROP
public static final LogLevelValue DEFAULT_LOG_LEVEL
public static final java.lang.String SYSLOG_FACILITY_CONFIG_PROP
public static final SyslogFacilityValue DEFAULT_SYSLOG_FACILITY
public static final java.lang.String SUBSYSTEM_CONFIG_PROP
public static java.util.Properties readConfigFile(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.net.URL url) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.lang.String path) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.io.InputStream input, boolean okToClose) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.io.Reader reader, boolean okToClose) throws java.io.IOException
java.io.IOException
public static java.util.Properties readConfigFile(java.io.BufferedReader rdr) throws java.io.IOException
Properties
instance.
Note: multiple keys value are concatenated using a comma - it is up to
the caller to know which keys are expected to have multiple values and handle
the split accordinglyrdr
- The BufferedReader
for reading the filejava.io.IOException
- If failed to read or malformed contentpublic static boolean parseBooleanValue(java.lang.String v)
v
- Checks if the value is "yes", "y"
or "on" or "true".null
/empty values are
interpreted as false
public static java.lang.String yesNoValueOf(boolean flag)
flag
- The required statetrue
, "no" otherwisepublic static BuiltinCiphers.ParseResult getCiphers(PropertyResolver props)
props
- The PropertyResolver
- ignored if null
/emptyParseResult
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 duplicatesCIPHERS_CONFIG_PROP
,
BuiltinCiphers.parseCiphersList(String)
public static BuiltinMacs.ParseResult getMacs(PropertyResolver props)
props
- The PropertyResolver
- ignored if null
/emptyParseResult
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 duplicatesMACS_CONFIG_PROP
,
BuiltinMacs.parseMacsList(String)
public static BuiltinSignatures.ParseResult getSignatures(PropertyResolver props)
props
- The PropertyResolver
- ignored if null
/emptyParseResult
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 duplicatesHOST_KEY_ALGORITHMS_CONFIG_PROP
,
BuiltinSignatures.parseSignatureList(String)
public static BuiltinDHFactories.ParseResult getKexFactories(PropertyResolver props)
props
- The PropertyResolver
- ignored if null
/emptyParseResult
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 duplicatesKEX_ALGORITHMS_CONFIG_PROP
,
BuiltinDHFactories.parseDHFactoriesList(String)
public static CompressionFactory getCompression(PropertyResolver props)
props
- The PropertyResolver
- ignored if null
/emptyNamedFactory
for the configured value.
null
if no configuration or unknown name specifiedpublic 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:
Cipher
s - via the CIPHERS_CONFIG_PROP
Mac
s - via the MACS_CONFIG_PROP
Signature
s - via the HOST_KEY_ALGORITHMS_CONFIG_PROP
Compression
- via the COMPRESSION_PROP
M
- The generic factory managermanager
- The AbstractFactoryManager
to configureprops
- 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 usedlenient
- If true
then any unknown configuration values are ignored.
Otherwise an IllegalArgumentException
is thrownignoreUnsupported
- 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 thrownpublic static <M extends AbstractFactoryManager> M configureCiphers(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureCiphers(M manager, java.lang.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, java.lang.String value, boolean lenient, 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, java.lang.String value, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, PropertyResolver props, boolean lenient, java.util.function.Function<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer, boolean ignoreUnsupported)
M
- The generic factory managermanager
- The AbstractFactoryManager
to set up (may not be null
)props
- The (non-null
) PropertyResolver
containing the configurationlenient
- If true
then any unknown/unsupported configuration
values are ignored. Otherwise an IllegalArgumentException
is thrownxformer
- 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 thrownKEX_ALGORITHMS_CONFIG_PROP
,
DEFAULT_KEX_ALGORITHMS
public static <M extends AbstractFactoryManager> M configureKeyExchanges(M manager, java.lang.String value, boolean lenient, java.util.function.Function<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureCompression(M manager, PropertyResolver props, boolean lenient, boolean ignoreUnsupported)
CompressionConfigValue
s.M
- The generic factory managermanager
- The AbstractFactoryManager
to configureprops
- The configuration Properties
lenient
- If true
and an unknown value is provided then
it is ignoredignoreUnsupported
- If false
then check if the compression
is currently supported before setting itpublic static <M extends AbstractFactoryManager> M configureCompression(M manager, java.lang.String value, boolean lenient, boolean ignoreUnsupported)