public final class SshConfigFileReader extends Object
Modifier and Type | Method and Description |
---|---|
static <C extends SshClient> |
configure(C client,
Properties props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configure(M manager,
Properties props,
boolean lenient,
boolean ignoreUnsupported)
Configures an
AbstractFactoryManager with the values read from
some configuration. |
static <S extends SshServer> |
configure(S server,
Properties props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureCiphers(M manager,
Properties props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureCiphers(M manager,
String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureCompression(M manager,
Properties props,
boolean lenient,
boolean ignoreUnsupported)
Configure the factory manager using one of the known
CompressionConfigValue s. |
static <M extends AbstractFactoryManager> |
configureCompression(M manager,
String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureKeyExchanges(M manager,
Properties props,
boolean lenient,
Transformer<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureKeyExchanges(M manager,
String value,
boolean lenient,
Transformer<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureMacs(M manager,
Properties props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureMacs(M manager,
String value,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureSignatures(M manager,
Properties props,
boolean lenient,
boolean ignoreUnsupported) |
static <M extends AbstractFactoryManager> |
configureSignatures(M manager,
String value,
boolean lenient,
boolean ignoreUnsupported) |
static Boolean |
getBoolean(Properties props,
String name) |
static boolean |
getBooleanProperty(Properties props,
String name,
boolean defaultValue) |
static BuiltinCiphers.ParseResult |
getCiphers(Properties props) |
static CompressionFactory |
getCompression(Properties props) |
static Integer |
getInteger(Properties props,
String name) |
static int |
getIntProperty(Properties props,
String name,
int defaultValue) |
static BuiltinDHFactories.ParseResult |
getKexFactories(Properties props) |
static Long |
getLong(Properties props,
String name) |
static long |
getLongProperty(Properties props,
String name,
long defaultValue) |
static BuiltinMacs.ParseResult |
getMacs(Properties props) |
static BuiltinSignatures.ParseResult |
getSignatures(Properties props) |
static boolean |
parseBooleanValue(String v) |
static boolean |
parseBooleanValue(String v,
boolean defaultValue) |
static Properties |
readConfigFile(BufferedReader rdr)
Reads the configuration file contents into a
Properties instance. |
static Properties |
readConfigFile(File file) |
static Properties |
readConfigFile(InputStream input,
boolean okToClose) |
static Properties |
readConfigFile(Path path,
OpenOption... options) |
static Properties |
readConfigFile(Reader reader,
boolean okToClose) |
static Properties |
readConfigFile(String path) |
static Properties |
readConfigFile(URL url) |
static String |
yesNoValueOf(boolean flag)
Returns a "yes" or "no" value based on the input
parameter
|
public static final char COMMENT_CHAR
public static final String BANNER_CONFIG_PROP
public static final String COMPRESSION_PROP
public static final String DEFAULT_COMPRESSION
public static final String ALLOW_TCP_FORWARDING_CONFIG_PROP
public static final String DEFAULT_TCP_FORWARDING
public static final boolean DEFAULT_TCP_FORWARDING_VALUE
public static final String ALLOW_AGENT_FORWARDING_CONFIG_PROP
public static final String DEFAULT_AGENT_FORWARDING
public static final boolean DEFAULT_AGENT_FORWARDING_VALUE
public static final String ALLOW_X11_FORWARDING_CONFIG_PROP
public static final String DEFAULT_X11_FORWARDING
public static final boolean DEFAULT_X11_FORWARDING_VALUE
public static final String MAX_SESSIONS_CONFIG_PROP
public static final int DEFAULT_MAX_SESSIONS
public static final String PASSWORD_AUTH_CONFIG_PROP
public static final String DEFAULT_PASSWORD_AUTH
public static final boolean DEFAULT_PASSWORD_AUTH_VALUE
public static final String LISTEN_ADDRESS_CONFIG_PROP
public static final String DEFAULT_BIND_ADDRESS
public static final String PORT_CONFIG_PROP
public static final int DEFAULT_PORT
public static final String KEEP_ALIVE_CONFIG_PROP
public static final boolean DEFAULT_KEEP_ALIVE
public static final String USE_DNS_CONFIG_PROP
public static final boolean DEFAULT_USE_DNS
public static final String PUBKEY_AUTH_CONFIG_PROP
public static final String DEFAULT_PUBKEY_AUTH
public static final boolean DEFAULT_PUBKEY_AUTH_VALUE
public static final String AUTH_KEYS_FILE_CONFIG_PROP
public static final String MAX_AUTH_TRIES_CONFIG_PROP
public static final int DEFAULT_MAX_AUTH_TRIES
public static final String MAX_STARTUPS_CONFIG_PROP
public static final int DEFAULT_MAX_STARTUPS
public static final String LOGIN_GRACE_TIME_CONFIG_PROP
public static final long DEFAULT_LOGIN_GRACE_TIME
public static final String KEY_REGENERATE_INTERVAL_CONFIG_PROP
public static final long DEFAULT_REKEY_TIME_LIMIT
public static final String CIPHERS_CONFIG_PROP
public static final String DEFAULT_CIPHERS
public static final String MACS_CONFIG_PROP
public static final String DEFAULT_MACS
public static final String KEX_ALGORITHMS_CONFIG_PROP
public static final String DEFAULT_KEX_ALGORITHMS
public static final String HOST_KEY_ALGORITHMS_CONFIG_PROP
public static final String DEFAULT_HOST_KEY_ALGORITHMS
public static final String LOG_LEVEL_CONFIG_PROP
public static final LogLevelValue DEFAULT_LOG_LEVEL
public static final String SYSLOG_FACILITY_CONFIG_PROP
public static final SyslogFacilityValue DEFAULT_SYSLOG_FACILITY
public static final String SUBSYSTEM_CONFIG_PROP
public static Properties readConfigFile(File file) throws IOException
IOException
public static Properties readConfigFile(Path path, OpenOption... options) throws IOException
IOException
public static Properties readConfigFile(URL url) throws IOException
IOException
public static Properties readConfigFile(String path) throws IOException
IOException
public static Properties readConfigFile(InputStream input, boolean okToClose) throws IOException
IOException
public static Properties readConfigFile(Reader reader, boolean okToClose) throws IOException
IOException
public static Properties readConfigFile(BufferedReader rdr) throws 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 fileIOException
- If failed to read or malformed contentpublic static long getLongProperty(Properties props, String name, long defaultValue)
props
- The Properties
- ignored if null
/emptyname
- The property namedefaultValue
- The default value to return if the specified property
does not exist in the properties map or is an empty stringNumberFormatException
- if malformed valuepublic static Long getLong(Properties props, String name)
props
- The Properties
- ignored if null
/emptyname
- The property nameLong
value or null
if property not found or
empty stringNumberFormatException
- if malformed valuepublic static int getIntProperty(Properties props, String name, int defaultValue)
props
- The Properties
- ignored if null
/emptyname
- The property namedefaultValue
- The default value to return if the specified property
does not exist in the properties map or is an empty stringNumberFormatException
- if malformed valuepublic static Integer getInteger(Properties props, String name)
props
- The Properties
- ignored if null
/emptyname
- The property nameInteger
value or null
if property not found or
empty stringNumberFormatException
- if malformed valuepublic static boolean getBooleanProperty(Properties props, String name, boolean defaultValue)
props
- The Properties
- ignored if null
/emptyname
- The property namedefaultValue
- The default value to return if the specified property
does not exist in the properties map or is an empty stringNumberFormatException
- if malformed valuepublic static Boolean getBoolean(Properties props, String name)
props
- The Properties
- ignored if null
/emptyname
- The property nameBoolean
value or null
if property not found or
empty stringNumberFormatException
- if malformed valuepublic static boolean parseBooleanValue(String v, boolean defaultValue)
v
- The value to parse - if null
/empty then the default
value is returned, otherwise parseBooleanValue(String)
is useddefaultValue
- The default value to return if null
/empty
input stringpublic static boolean parseBooleanValue(String v)
v
- Checks if the value is "yes", "y"
or "on" or "true".null
/empty values are
intrepreted as false
public static String yesNoValueOf(boolean flag)
flag
- The required statetrue
, "no" otherwisepublic static BuiltinCiphers.ParseResult getCiphers(Properties props)
props
- The Properties
- 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(Properties props)
props
- The Properties
- 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(Properties props)
props
- The Properties
- 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(Properties props)
props
- The Properties
- 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(Properties props)
props
- The Properties
- ignored if null
/emptyNamedFactory
for the configured value.
null
if no configuration or unknown name specifiedpublic static <S extends SshServer> S configure(S server, Properties props, boolean lenient, boolean ignoreUnsupported)
public static <C extends SshClient> C configure(C client, Properties props, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configure(M manager, Properties 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 Properties
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, Properties props, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureCiphers(M manager, String value, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureSignatures(M manager, Properties props, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureSignatures(M manager, String value, boolean lenient, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureMacs(M manager, Properties props, 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 configureKeyExchanges(M manager, Properties props, boolean lenient, Transformer<? 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
) Properties
containing the configurationlenient
- If true
then any unknown/unsupported configuration
values are ignored. Otherwise an IllegalArgumentException
is thrownxformer
- A Transformer
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, String value, boolean lenient, Transformer<? super DHFactory,? extends NamedFactory<KeyExchange>> xformer, boolean ignoreUnsupported)
public static <M extends AbstractFactoryManager> M configureCompression(M manager, Properties 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, String value, boolean lenient, boolean ignoreUnsupported)
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.