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
JSchException
void setKnownHosts(java.io.InputStream input) throws JSchException
JSchException
private void addInvalidLine(java.lang.String line) throws JSchException
JSchException
java.lang.String getKnownHostsFile()
public java.lang.String getKnownHostsRepositoryID()
HostKeyRepository
getKnownHostsRepositoryID
in interface HostKeyRepository
public int check(java.lang.String host, byte[] key)
HostKeyRepository
host
is included with the key
.check
in interface HostKeyRepository
HostKeyRepository.NOT_INCLUDED
,
HostKeyRepository.OK
,
HostKeyRepository.CHANGED
public void add(HostKey hostkey, UserInfo userinfo)
HostKeyRepository
hostkey
add
in interface HostKeyRepository
hostkey
- a host key to be addeduserinfo
- a user interface for showing messages or promping inputs.UserInfo
public HostKey[] getHostKey()
HostKeyRepository
getHostKey
in interface HostKeyRepository
HostKeyRepository.getHostKey(String host, String type)
public HostKey[] getHostKey(java.lang.String host, java.lang.String type)
HostKeyRepository
getHostKey
in interface HostKeyRepository
host
- 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)
HostKeyRepository
host
, type
.remove
in interface HostKeyRepository
HostKeyRepository.remove(String host, String type, byte[] key)
public void remove(java.lang.String host, java.lang.String type, byte[] key)
HostKeyRepository
host
, type
and key
.remove
in interface HostKeyRepository
protected void sync() throws java.io.IOException
java.io.IOException
protected void sync(java.lang.String foo) throws java.io.IOException
java.io.IOException
void dump(java.io.OutputStream out) throws java.io.IOException
java.io.IOException
private 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