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_hostsfile- See Also:
- sshd(8) man page
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classKnownHostEntry.LazyDefaultConfigFileHolder
-
Field Summary
Fields Modifier and Type Field Description private KnownHostHashValuehashedEntryprivate AuthorizedKeyEntrykeyEntryprivate java.lang.Stringlineprivate java.lang.Stringmarkerstatic charMARKER_INDICATORCharacter that denotes that start of a markerstatic java.lang.StringSTD_HOSTS_FILENAMEStandard 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.StringgetConfigLine()static java.nio.file.PathgetDefaultKnownHostsFile()KnownHostHashValuegetHashedEntry()AuthorizedKeyEntrygetKeyEntry()java.lang.StringgetMarker()booleanisHostMatch(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 KnownHostEntryparseKnownHostEntry(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)voidsetConfigLine(java.lang.String line)voidsetHashedEntry(KnownHostHashValue hashedEntry)voidsetKeyEntry(AuthorizedKeyEntry keyEntry)voidsetMarker(java.lang.String marker)java.lang.StringtoString()-
Methods inherited from class org.apache.sshd.client.config.hosts.HostPatternsHolder
findMatchingEntries, findMatchingEntries, getPatterns, isHostMatch, isHostMatch, isPortMatch, 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:HostPatternsHolderChecks if a given host name / address matches the entry's host pattern(s)- Overrides:
isHostMatchin classHostPatternsHolder- Parameters:
host- The host name / address - ignored ifnull/emptyport- The connection port- Returns:
trueif the name / address matches the pattern(s)- See Also:
HostPatternsHolder.isHostMatch(String, Pattern)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDefaultKnownHostsFile
public static java.nio.file.Path getDefaultKnownHostsFile()
- Returns:
- The default
Pathlocation 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- TheBufferedReaderto use- Returns:
- The
Listof 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)
-
-