public class KnownHostEntry extends HostPatternsHolder
known_hosts
fileModifier and Type | Class and Description |
---|---|
private static class |
KnownHostEntry.LazyDefaultConfigFileHolder |
Modifier and Type | Field and 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 marker
|
static java.lang.String |
STD_HOSTS_FILENAME
Standard OpenSSH config file name
|
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 and Description |
---|
KnownHostEntry() |
KnownHostEntry(java.lang.String line) |
Modifier and Type | Method and 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> |
parseKnownHostEntry(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 entries
|
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.io.File file) |
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.io.InputStream inStream,
boolean okToClose) |
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.nio.file.Path path,
java.nio.file.OpenOption... options) |
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.io.Reader rdr,
boolean okToClose) |
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.lang.String filePath) |
static java.util.List<KnownHostEntry> |
readKnownHostEntries(java.net.URL url) |
void |
setConfigLine(java.lang.String line) |
void |
setHashedEntry(KnownHostHashValue hashedEntry) |
void |
setKeyEntry(AuthorizedKeyEntry keyEntry) |
void |
setMarker(java.lang.String marker) |
java.lang.String |
toString() |
findMatchingEntries, findMatchingEntries, getPatterns, isHostMatch, isHostMatch, isSpecificHostPattern, isValidPatternChar, parsePatterns, parsePatterns, setPatterns, toPattern
public static final char MARKER_INDICATOR
public static final java.lang.String STD_HOSTS_FILENAME
private java.lang.String line
private java.lang.String marker
private AuthorizedKeyEntry keyEntry
private KnownHostHashValue hashedEntry
public KnownHostEntry()
public KnownHostEntry(java.lang.String line)
line
- The original line from which this entry was createdpublic java.lang.String getConfigLine()
public void setConfigLine(java.lang.String line)
public java.lang.String getMarker()
public void setMarker(java.lang.String marker)
public AuthorizedKeyEntry getKeyEntry()
public void setKeyEntry(AuthorizedKeyEntry keyEntry)
public KnownHostHashValue getHashedEntry()
public void setHashedEntry(KnownHostHashValue hashedEntry)
public boolean isHostMatch(java.lang.String host, int port)
HostPatternsHolder
isHostMatch
in class HostPatternsHolder
host
- The host name / address - ignored if null
/emptyport
- The connection porttrue
if the name / address matches the pattern(s)HostPatternsHolder.isHostMatch(String, Pattern)
public java.lang.String toString()
toString
in class java.lang.Object
public static java.nio.file.Path getDefaultKnownHostsFile()
Path
location of the OpenSSH known hosts filepublic static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.net.URL url) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.lang.String filePath) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.InputStream inStream, boolean okToClose) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.Reader rdr, boolean okToClose) throws java.io.IOException
java.io.IOException
public static java.util.List<KnownHostEntry> readKnownHostEntries(java.io.BufferedReader rdr) throws java.io.IOException
rdr
- The BufferedReader
to useList
of read KnownHostEntry
-iesjava.io.IOException
- If failed to parse the read configurationpublic static KnownHostEntry parseKnownHostEntry(java.lang.String line)
public static <E extends KnownHostEntry> E parseKnownHostEntry(E entry, java.lang.String data)