Class KnownHostEntry
- java.lang.Object
-
- org.apache.sshd.client.config.hosts.HostPatternsHolder
-
- org.apache.sshd.client.config.hosts.KnownHostEntry
-
public class KnownHostEntry extends HostPatternsHolder
Contains a representation of an entry in theknown_hosts
file- See Also:
- sshd(8) man page
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
KnownHostEntry.LazyDefaultConfigFileHolder
-
Field Summary
Fields Modifier and Type Field Description private KnownHostHashValue
hashedEntry
private AuthorizedKeyEntry
keyEntry
private java.lang.String
line
private java.lang.String
marker
static char
MARKER_INDICATOR
Character that denotes that start of a markerstatic java.lang.String
STD_HOSTS_FILENAME
Standard OpenSSH config file name-
Fields inherited from class org.apache.sshd.client.config.hosts.HostPatternsHolder
ALL_HOSTS_PATTERN, NEGATION_CHAR_PATTERN, NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM, NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM, PATTERN_CHARS, PORT_VALUE_DELIMITER, SINGLE_CHAR_PATTERN, WILDCARD_PATTERN
-
-
Constructor Summary
Constructors Constructor Description KnownHostEntry()
KnownHostEntry(java.lang.String line)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getConfigLine()
static java.nio.file.Path
getDefaultKnownHostsFile()
KnownHostHashValue
getHashedEntry()
AuthorizedKeyEntry
getKeyEntry()
java.lang.String
getMarker()
boolean
isHostMatch(java.lang.String host, int port)
Checks if a given host name / address matches the entry's host pattern(s)static <E extends KnownHostEntry>
EparseKnownHostEntry(E entry, java.lang.String data)
static KnownHostEntry
parseKnownHostEntry(java.lang.String line)
static java.util.List<KnownHostEntry>
readKnownHostEntries(java.io.BufferedReader rdr)
Reads configuration entriesstatic java.util.List<KnownHostEntry>
readKnownHostEntries(java.io.InputStream inStream, boolean okToClose)
static java.util.List<KnownHostEntry>
readKnownHostEntries(java.io.Reader rdr, boolean okToClose)
static java.util.List<KnownHostEntry>
readKnownHostEntries(java.net.URL url)
static java.util.List<KnownHostEntry>
readKnownHostEntries(java.nio.file.Path path, java.nio.file.OpenOption... options)
void
setConfigLine(java.lang.String line)
void
setHashedEntry(KnownHostHashValue hashedEntry)
void
setKeyEntry(AuthorizedKeyEntry keyEntry)
void
setMarker(java.lang.String marker)
java.lang.String
toString()
-
Methods inherited from class org.apache.sshd.client.config.hosts.HostPatternsHolder
findMatchingEntries, findMatchingEntries, getPatterns, isHostMatch, isHostMatch, isSpecificHostPattern, isValidPatternChar, parsePatterns, parsePatterns, setPatterns, toPattern
-
-
-
-
Field Detail
-
MARKER_INDICATOR
public static final char MARKER_INDICATOR
Character that denotes that start of a marker- See Also:
- Constant Field Values
-
STD_HOSTS_FILENAME
public static final java.lang.String STD_HOSTS_FILENAME
Standard OpenSSH config file name- See Also:
- Constant Field Values
-
line
private java.lang.String line
-
marker
private java.lang.String marker
-
keyEntry
private AuthorizedKeyEntry keyEntry
-
hashedEntry
private KnownHostHashValue hashedEntry
-
-
Method Detail
-
getConfigLine
public java.lang.String getConfigLine()
- Returns:
- The original line from which this entry was created
-
setConfigLine
public void setConfigLine(java.lang.String line)
-
getMarker
public java.lang.String getMarker()
-
setMarker
public void setMarker(java.lang.String marker)
-
getKeyEntry
public AuthorizedKeyEntry getKeyEntry()
-
setKeyEntry
public void setKeyEntry(AuthorizedKeyEntry keyEntry)
-
getHashedEntry
public KnownHostHashValue getHashedEntry()
-
setHashedEntry
public void setHashedEntry(KnownHostHashValue hashedEntry)
-
isHostMatch
public boolean isHostMatch(java.lang.String host, int port)
Description copied from class:HostPatternsHolder
Checks if a given host name / address matches the entry's host pattern(s)- Overrides:
isHostMatch
in classHostPatternsHolder
- Parameters:
host
- The host name / address - ignored ifnull
/emptyport
- The connection port- Returns:
true
if the name / address matches the pattern(s)- See Also:
HostPatternsHolder.isHostMatch(String, Pattern)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getDefaultKnownHostsFile
public static java.nio.file.Path getDefaultKnownHostsFile()
- Returns:
- The default
Path
location of the OpenSSH known hosts file
-
readKnownHostEntries
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
- Throws:
java.io.IOException
-
readKnownHostEntries
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
readKnownHostEntries
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.InputStream inStream, boolean okToClose) throws java.io.IOException
- Throws:
java.io.IOException
-
readKnownHostEntries
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.Reader rdr, boolean okToClose) throws java.io.IOException
- Throws:
java.io.IOException
-
readKnownHostEntries
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.BufferedReader rdr) throws java.io.IOException
Reads configuration entries- Parameters:
rdr
- TheBufferedReader
to use- Returns:
- The
List
of readKnownHostEntry
-ies - Throws:
java.io.IOException
- If failed to parse the read configuration
-
parseKnownHostEntry
public static KnownHostEntry parseKnownHostEntry(java.lang.String line)
-
parseKnownHostEntry
public static <E extends KnownHostEntry> E parseKnownHostEntry(E entry, java.lang.String data)
-
-