public class KnownHosts extends Object implements HostKeyRepository
HostKeyRepository
, using
a local file to store the keys.
I see no reason this class has to be public.
CHANGED, NOT_INCLUDED, OK
Modifier and Type | Method and Description |
---|---|
void |
add(HostKey hostkey,
UserInfo userinfo)
Adds a hostname-key-pair to the repository.
|
int |
check(String host,
byte[] key)
Checks whether some host has a given key.
|
HostKey[] |
getHostKey()
returns all host keys in this repository.
|
HostKey[] |
getHostKey(String host,
String type)
returns all host keys of a certain host.
|
String |
getKnownHostsRepositoryID()
returns an identifier for this repository.
|
void |
remove(String host,
String type)
Removes a host key if there exists mached key with
host , type . |
void |
remove(String host,
String type,
byte[] key)
removes a specific key of a host from the repository.
|
protected void |
sync() |
protected void |
sync(String foo) |
public String getKnownHostsRepositoryID()
HostKeyRepository
This will be used for messages to the user speaking about the repository.
getKnownHostsRepositoryID
in interface HostKeyRepository
public int check(String host, byte[] key)
HostKeyRepository
check
in interface HostKeyRepository
host
- the host name to checkkey
- the public key the remote host
uses.HostKeyRepository.OK
(this host is known to use
this key), HostKeyRepository.NOT_INCLUDED
(the host is unknown) or
HostKeyRepository.CHANGED
(the host is known to use another key).public void add(HostKey hostkey, UserInfo userinfo)
HostKeyRepository
add
in interface HostKeyRepository
hostkey
- the key to adduserinfo
- an UserInfo object which may be used to ask the
user whether to create the file (and directory), or other
similar questions, if necessary.public HostKey[] getHostKey()
HostKeyRepository
getHostKey(null,null)
.
This method should have been named getHostKeys()
.getHostKey
in interface HostKeyRepository
public HostKey[] getHostKey(String host, String type)
HostKeyRepository
getHostKeys(...)
.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(String host, String type)
HostKeyRepository
host
, type
.remove
in interface HostKeyRepository
HostKeyRepository.remove(String host, String type, byte[] key)
public void remove(String host, String type, byte[] key)
HostKeyRepository
remove
in interface HostKeyRepository
host
- the host name whose key is to remove.type
- the type of key to remove. If null, all keys of
this host will be removed (without looking at key
).key
- the key to be removed. If null, all keys of the
given type and host will be removed.protected void sync() throws IOException
IOException
protected void sync(String foo) throws IOException
IOException
This is an inofficial Javadoc created by PaĆlo Ebermann. Have a look at the official homepage.