Package com.jcraft.jsch
Class KnownHosts
- java.lang.Object
-
- com.jcraft.jsch.KnownHosts
-
- All Implemented Interfaces:
HostKeyRepository
public class KnownHosts extends Object implements HostKeyRepository
-
-
Field Summary
-
Fields inherited from interface com.jcraft.jsch.HostKeyRepository
CHANGED, NOT_INCLUDED, OK
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(HostKey hostkey, UserInfo userinfo)
Adds a host keyhostkey
int
check(String host, byte[] key)
Checks ifhost
is included with thekey
.HostKey[]
getHostKey()
Retuns a list for host keys managed in this repository.HostKey[]
getHostKey(String host, String type)
Retuns a list for host keys managed in this repository.String
getKnownHostsRepositoryID()
Returns id of this repository.void
remove(String host, String type)
Removes a host key if there exists mached key withhost
,type
.void
remove(String host, String type, byte[] key)
Removes a host key if there exists a matched key withhost
,type
andkey
.protected void
sync()
protected void
sync(String foo)
-
-
-
Method Detail
-
getKnownHostsRepositoryID
public String getKnownHostsRepositoryID()
Description copied from interface:HostKeyRepository
Returns id of this repository.- Specified by:
getKnownHostsRepositoryID
in interfaceHostKeyRepository
- Returns:
- identity in String
-
check
public int check(String host, byte[] key)
Description copied from interface:HostKeyRepository
Checks ifhost
is included with thekey
.- Specified by:
check
in interfaceHostKeyRepository
- Returns:
- #NOT_INCLUDED, #OK or #CHANGED
- See Also:
HostKeyRepository.NOT_INCLUDED
,HostKeyRepository.OK
,HostKeyRepository.CHANGED
-
add
public void add(HostKey hostkey, UserInfo userinfo)
Description copied from interface:HostKeyRepository
Adds a host keyhostkey
- Specified by:
add
in interfaceHostKeyRepository
- Parameters:
hostkey
- a host key to be addeduserinfo
- a user interface for showing messages or promping inputs.- See Also:
UserInfo
-
getHostKey
public HostKey[] getHostKey()
Description copied from interface:HostKeyRepository
Retuns a list for host keys managed in this repository.- Specified by:
getHostKey
in interfaceHostKeyRepository
- See Also:
HostKeyRepository.getHostKey(String host, String type)
-
getHostKey
public HostKey[] getHostKey(String host, String type)
Description copied from interface:HostKeyRepository
Retuns a list for host keys managed in this repository.- Specified by:
getHostKey
in interfaceHostKeyRepository
- Parameters:
host
- a hostname used in searching host keys. Ifnull
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". Ifnull
is given, a key type type will not be ignored.
-
remove
public void remove(String host, String type)
Description copied from interface:HostKeyRepository
Removes a host key if there exists mached key withhost
,type
.- Specified by:
remove
in interfaceHostKeyRepository
- See Also:
HostKeyRepository.remove(String host, String type, byte[] key)
-
remove
public void remove(String host, String type, byte[] key)
Description copied from interface:HostKeyRepository
Removes a host key if there exists a matched key withhost
,type
andkey
.- Specified by:
remove
in interfaceHostKeyRepository
-
sync
protected void sync() throws IOException
- Throws:
IOException
-
sync
protected void sync(String foo) throws IOException
- Throws:
IOException
-
-