Class KnownHostEntryReader
java.lang.Object
org.eclipse.jgit.internal.transport.sshd.KnownHostEntryReader
Apache MINA sshd 2.0.0 KnownHostEntry cannot read a host entry line like
"host:port ssh-rsa "; it complains about an illegal character in the
host name (correct would be "[host]:port"). The default known_hosts reader
also aborts reading on the first error.
This reader is a bit more robust and tries to handle this case if there is only one colon (otherwise it might be an IPv6 address (without port)), and it skips and logs invalid entries, but still returns all other valid entries from the file.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
private static org.apache.sshd.client.config.hosts.KnownHostEntry
parseHostEntry
(String line) private static Collection
<org.apache.sshd.client.config.hosts.HostPatternValue> parsePatterns
(String text) static List
<org.apache.sshd.client.config.hosts.KnownHostEntry> readFromFile
(Path path) Reads a known_hosts file and returns all valid entries.
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG
-
-
Constructor Details
-
KnownHostEntryReader
private KnownHostEntryReader()
-
-
Method Details
-
readFromFile
public static List<org.apache.sshd.client.config.hosts.KnownHostEntry> readFromFile(Path path) throws IOException Reads a known_hosts file and returns all valid entries. Invalid entries are skipped (and a message is logged).- Parameters:
path
- of the file to read- Returns:
- a
List
of all valid entries read from the file - Throws:
IOException
- if the file cannot be read.
-
clean
-
parseHostEntry
-
parsePatterns
private static Collection<org.apache.sshd.client.config.hosts.HostPatternValue> parsePatterns(String text)
-