Top Description Inners Fields Constructors Methods
org.apache.sshd.client.config.hosts

public Class HostConfigEntry

extends HostPatternsHolder
implements MutableUserHolder
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.auth.MutableUserHolder, org.apache.sshd.common.auth.UsernameHolder
Imports
java.io.BufferedReader, .File, .IOException, .InputStream, .InputStreamReader, .OutputStream, .OutputStreamWriter, .Reader, .StreamCorruptedException, .Writer, java.net.InetAddress, .URL, java.nio.charset.StandardCharsets, java.nio.file.Files, .OpenOption, .Path, java.util.ArrayList, .Arrays, .Collection, .Collections, .List, .Map, .Map.Entry, .NavigableSet, .Objects, .TreeMap, org.apache.sshd.common.SshConstants, org.apache.sshd.common.auth.MutableUserHolder, org.apache.sshd.common.config.ConfigFileReaderSupport, org.apache.sshd.common.config.keys.PublicKeyEntry, org.apache.sshd.common.util.GenericUtils, .MapEntryUtils, .OsUtils, .ValidateUtils, org.apache.sshd.common.util.io.IoUtils, .PathUtils, org.apache.sshd.common.util.io.input.NoCloseInputStream, .NoCloseReader, org.apache.sshd.common.util.io.output.NoCloseOutputStream

Represents an entry in the client's configuration file as defined by the ssh_config configuration file format
Author
Apache MINA SSHD Project
See Also
OpenSSH Config File Examples

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final String
public static final boolean
public static final String
EXCLUSIVE_IDENTITIES_CONFIG_PROP

Use only the identities specified in the host entry (if any)

protected Boolean
public static final NavigableSet<String>
EXPLICIT_PROPERTIES

A case insensitive NavigableSet of the properties that receive special handling

protected String
public static final String
public static final String
protected String
protected final Collection<String>
public static final String
IDENTITY_AGENT

The IdentityAgent configuration.

public static final String
public static final char
public static final char
public static final char
public static final String
public static final String
public static final char
protected int
public static final String
protected final Map<String, String>
public static final String
protected String
public static final char
public static final char
public static final char
public static final String
STD_CONFIG_FILENAME

Standard OpenSSH config file name

public static final String
protected String
Inherited from org.apache.sshd.client.config.hosts.HostPatternsHolder:
ALL_HOSTS_PATTERNNEGATION_CHAR_PATTERNNON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIMNON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIMPATTERN_CHARSPORT_VALUE_DELIMITERSINGLE_CHAR_PATTERNWILDCARD_PATTERN

Constructor Summary

AccessConstructor and Description
public
public
HostConfigEntry(String pattern, String host, int port, String username)

public
HostConfigEntry(String pattern, String host, int port, String username, String proxyJump)

Method Summary

Modifier and TypeMethod and Description
public void
addIdentity(Path
A Path to a file that contains an identity key - never null
path
)

public void
addIdentity(String
The identity path to add - never null
id
)

Adds a path to an identity file

public <A extends Appendable> A
append(A sb)

public static <A extends Appendable> A
public static <
The Appendable type
A extends Appendable
>
A

Returns:

The target appender after having appended (or not) the value
appendNonEmptyPort
(A
The target appender
sb
,
String
The property name - never null/empty
name
,
int
The port value - ignored if non-positive
port
)

public static <
The Appendable type
A extends Appendable
>
A

Returns:

The target appender after having appended (or not) the value
appendNonEmptyProperties
(A
The target appender
sb
,
Map<String, ?>
The Map of properties - ignored if null/empty
props
)

Appends the extra properties - while skipping the EXPLICIT_PROPERTIES ones

public static <
The Appendable type
A extends Appendable
>
A

Returns:

The target appender after having appended (or not) the value
appendNonEmptyProperty
(A
The target appender
sb
,
String
The property name - never null/empty
name
,
Object
The property value - ignored if null

Note

if the string representation of the value contains any commas, they are assumed to indicate a multi-valued property which is broken down to individual lines - one per value.

value
)

public static <
The Appendable type
A extends Appendable
>
A

Returns:

The target appender after having appended (or not) the value
appendNonEmptyValues
(A
The target appender
sb
,
String
The property name - never null/empty
name
,
Object...
The values to be added - one per line - ignored if null/empty
values
)

public static <
The Appendable type
A extends Appendable
>
A

Returns:

The target appender after having appended (or not) the value
appendNonEmptyValues
(A
The target appender
sb
,
String
The property name - never null/empty
name
,
Collection<?>
The values to be added - one per line - ignored if null/empty
values
)

public String

Returns:

The value before appending - null if no previous value
appendPropertyValue
(String
Property name - never null/empty
name
,
String
The value to be appended - ignored if null/empty
value
)

Appends a value using a comma to an existing one.

public void
collate(HostConfigEntry
The HostConfigEntry to merge.
that
)

Merges that into this via underride.

public static List<HostConfigEntry>

Returns:

A List of all the matching entries
findMatchingEntries
(String
The host name / address - ignored if null/empty
host
,
HostConfigEntry...
The HostConfigEntry-ies to scan - ignored if null/empty
entries
)

Locates all the matching entries for a give host name / address

public static List<HostConfigEntry>

Returns:

A List of all the matching entries
findMatchingEntries
(String
The host name / address - ignored if null/empty
host
,
Collection<? extends HostConfigEntry>
The HostConfigEntry-ies to scan - ignored if null/empty
entries
)

Locates all the matching entries for a give host name / address

public static Path

Returns:

The default Path location of the OpenSSH hosts entries configuration file
getDefaultHostConfigFile
()

public String

Returns:

The pattern(s) represented by this entry
getHost
()

public String

Returns:

The effective host name to connect to if the pattern matches
getHostName
()

public Collection<String>

Returns:

The current identities file paths - may be null/empty
getIdentities
()

public int

Returns:

A port override - if positive
getPort
()

public Map<String, String>

Returns:

A Map of extra properties that have been read - may be null/empty, or even contain some values that have been parsed and set as members of the entry (e.g., host, port, etc.)

Note

multi-valued keys use a comma-separated list of values

getProperties
()

public String

Returns:

Property value or null if no such property
getProperty
(String
Property name - never null/empty
name
)

public String

Returns:

The property value or the default one if no such property
getProperty
(String
Property name - never null/empty
name
,
String
Default value to return if no such property
defaultValue
)

public String

Returns:

the host to use as a proxy
getProxyJump
()

public String

Returns:

A username override - if not null/empty
getUsername
()

Implements org.apache.sshd.common.auth.UsernameHolder.getUsername.

public boolean

Returns:

true if must use only the identities in this entry
isIdentitiesOnly
()

public static List<String>

Returns:

A List of the encountered values
parseConfigValue
(String
The value - ignored if null/empty (after trimming)
value
)

Checks if this is a multi-value - allow space and comma

public void
processProperty(String
Property name - never null/empty
name
,
Collection<String>
The available values for the property
valsList
)

public static List<HostConfigEntry>
public static List<HostConfigEntry>
public static List<HostConfigEntry>
readHostConfigEntries(InputStream inStream, boolean okToClose)

public static List<HostConfigEntry>
readHostConfigEntries(Reader rdr, boolean okToClose)

public static List<HostConfigEntry>

Returns:

The List of read HostConfigEntry-ies
readHostConfigEntries
(BufferedReader
The BufferedReader to use
rdr
)

Reads configuration entries

public String

Returns:

The removed property value - null if no such property name
removeProperty
(String
Property name - never null/empty
name
)

public static String
resolveIdentityFilePath(String id, String host, int port, String username)

public void
public void
public void
setHostName(String hostName)

public void
public void
setIdentitiesOnly(boolean identitiesOnly)

public void
setPort(int port)

public void
setProperties(Map<String, String>
The properties to set - if null then an empty map is effectively set

Note

it is highly recommended to use a case insensitive key mapper.

properties
)

public String

Returns:

The previous property value - null if no such name
setProperty
(String
Property name - never null/empty
name
,
String
Property value - if null/empty then removeProperty(String) is called
value
)

Sets / Replaces the property value

public void
setProxyJump(String proxyJump)

public void
public static HostConfigEntryResolver

Returns:

A HostConfigEntryResolver wrapper using the entries
toHostConfigEntryResolver
(Collection<? extends HostConfigEntry>
The entries - ignored if null/empty
entries
)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public static void
writeHostConfigEntries(Path path, Collection<? extends HostConfigEntry> entries, OpenOption... options)

public static void
writeHostConfigEntries(OutputStream outputStream, boolean okToClose, Collection<? extends HostConfigEntry> entries)

Inherited from org.apache.sshd.client.config.hosts.HostPatternsHolder:
getPatternsisHostMatchisHostMatchisHostMatchisPortMatchisSpecificHostPatternisValidPatternCharparsePatternsparsePatternssetPatternstoPattern