public class KnownHosts extends java.lang.Object implements HostKeyRepository
| Modifier and Type | Class and Description |
|---|---|
(package private) class |
KnownHosts.HashedHostKey |
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
_known_hosts |
private static byte[] |
cr |
private MAC |
hmacsha1 |
private JSch |
jsch |
private java.lang.String |
known_hosts |
private java.util.Vector |
pool |
private static byte[] |
space |
CHANGED, NOT_INCLUDED, OK| Constructor and Description |
|---|
KnownHosts(JSch jsch) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(HostKey hostkey,
UserInfo userinfo)
Adds a host key
hostkey |
private void |
addInvalidLine(java.lang.String line) |
int |
check(java.lang.String host,
byte[] key)
Checks if
host is included with the key. |
(package private) HostKey |
createHashedHostKey(java.lang.String host,
byte[] key) |
private java.lang.String |
deleteSubString(java.lang.String hosts,
java.lang.String host) |
(package private) void |
dump(java.io.OutputStream out) |
private MAC |
getHMACSHA1() |
HostKey[] |
getHostKey()
Retuns a list for host keys managed in this repository.
|
HostKey[] |
getHostKey(java.lang.String host,
java.lang.String type)
Retuns a list for host keys managed in this repository.
|
(package private) java.lang.String |
getKnownHostsFile() |
java.lang.String |
getKnownHostsRepositoryID()
Returns id of this repository.
|
void |
remove(java.lang.String host,
java.lang.String type)
Removes a host key if there exists mached key with
host, type. |
void |
remove(java.lang.String host,
java.lang.String type,
byte[] key)
Removes a host key if there exists a matched key with
host, type and key. |
(package private) void |
setKnownHosts(java.io.InputStream input) |
(package private) void |
setKnownHosts(java.lang.String filename) |
protected void |
sync() |
protected void |
sync(java.lang.String foo) |
private static final java.lang.String _known_hosts
private JSch jsch
private java.lang.String known_hosts
private java.util.Vector pool
private MAC hmacsha1
private static final byte[] space
private static final byte[] cr
KnownHosts(JSch jsch)
void setKnownHosts(java.lang.String filename)
throws JSchException
JSchExceptionvoid setKnownHosts(java.io.InputStream input)
throws JSchException
JSchExceptionprivate void addInvalidLine(java.lang.String line)
throws JSchException
JSchExceptionjava.lang.String getKnownHostsFile()
public java.lang.String getKnownHostsRepositoryID()
HostKeyRepositorygetKnownHostsRepositoryID in interface HostKeyRepositorypublic int check(java.lang.String host,
byte[] key)
HostKeyRepositoryhost is included with the key.check in interface HostKeyRepositoryHostKeyRepository.NOT_INCLUDED,
HostKeyRepository.OK,
HostKeyRepository.CHANGEDpublic void add(HostKey hostkey, UserInfo userinfo)
HostKeyRepositoryhostkeyadd in interface HostKeyRepositoryhostkey - a host key to be addeduserinfo - a user interface for showing messages or promping inputs.UserInfopublic HostKey[] getHostKey()
HostKeyRepositorygetHostKey in interface HostKeyRepositoryHostKeyRepository.getHostKey(String host, String type)public HostKey[] getHostKey(java.lang.String host, java.lang.String type)
HostKeyRepositorygetHostKey in interface HostKeyRepositoryhost - a hostname used in searching host keys.
If null is given, every host key will be listed.type - a key type used in searching host keys,
and it should be "ssh-dss" or "ssh-rsa".
If null is given, a key type type will not be ignored.public void remove(java.lang.String host,
java.lang.String type)
HostKeyRepositoryhost, type.remove in interface HostKeyRepositoryHostKeyRepository.remove(String host, String type, byte[] key)public void remove(java.lang.String host,
java.lang.String type,
byte[] key)
HostKeyRepositoryhost, type and key.remove in interface HostKeyRepositoryprotected void sync()
throws java.io.IOException
java.io.IOExceptionprotected void sync(java.lang.String foo)
throws java.io.IOException
java.io.IOExceptionvoid dump(java.io.OutputStream out) throws java.io.IOException
java.io.IOExceptionprivate java.lang.String deleteSubString(java.lang.String hosts,
java.lang.String host)
private MAC getHMACSHA1()
HostKey createHashedHostKey(java.lang.String host, byte[] key) throws JSchException
JSchException