Package com.jcraft.jsch
Class KnownHosts
- java.lang.Object
-
- com.jcraft.jsch.KnownHosts
-
- All Implemented Interfaces:
HostKeyRepository
public class KnownHosts extends java.lang.Object implements HostKeyRepository
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classKnownHosts.HashedHostKey
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String_known_hostsprivate static byte[]crprivate MAChmacsha1private JSchjschprivate java.lang.Stringknown_hostsprivate java.util.Vectorpoolprivate static byte[]space-
Fields inherited from interface com.jcraft.jsch.HostKeyRepository
CHANGED, NOT_INCLUDED, OK
-
-
Constructor Summary
Constructors Constructor Description KnownHosts(JSch jsch)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(HostKey hostkey, UserInfo userinfo)Adds a host keyhostkeyprivate voidaddInvalidLine(java.lang.String line)intcheck(java.lang.String host, byte[] key)Checks ifhostis included with thekey.(package private) HostKeycreateHashedHostKey(java.lang.String host, byte[] key)private java.lang.StringdeleteSubString(java.lang.String hosts, java.lang.String host)(package private) voiddump(java.io.OutputStream out)private MACgetHMACSHA1()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.StringgetKnownHostsFile()java.lang.StringgetKnownHostsRepositoryID()Returns id of this repository.voidremove(java.lang.String host, java.lang.String type)Removes a host key if there exists mached key withhost,type.voidremove(java.lang.String host, java.lang.String type, byte[] key)Removes a host key if there exists a matched key withhost,typeandkey.(package private) voidsetKnownHosts(java.io.InputStream input)(package private) voidsetKnownHosts(java.lang.String filename)protected voidsync()protected voidsync(java.lang.String foo)
-
-
-
Field Detail
-
_known_hosts
private static final java.lang.String _known_hosts
- See Also:
- Constant Field Values
-
jsch
private JSch jsch
-
known_hosts
private java.lang.String known_hosts
-
pool
private java.util.Vector pool
-
hmacsha1
private MAC hmacsha1
-
space
private static final byte[] space
-
cr
private static final byte[] cr
-
-
Constructor Detail
-
KnownHosts
KnownHosts(JSch jsch)
-
-
Method Detail
-
setKnownHosts
void setKnownHosts(java.lang.String filename) throws JSchException- Throws:
JSchException
-
setKnownHosts
void setKnownHosts(java.io.InputStream input) throws JSchException- Throws:
JSchException
-
addInvalidLine
private void addInvalidLine(java.lang.String line) throws JSchException- Throws:
JSchException
-
getKnownHostsFile
java.lang.String getKnownHostsFile()
-
getKnownHostsRepositoryID
public java.lang.String getKnownHostsRepositoryID()
Description copied from interface:HostKeyRepositoryReturns id of this repository.- Specified by:
getKnownHostsRepositoryIDin interfaceHostKeyRepository- Returns:
- identity in String
-
check
public int check(java.lang.String host, byte[] key)Description copied from interface:HostKeyRepositoryChecks ifhostis included with thekey.- Specified by:
checkin 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:HostKeyRepositoryAdds a host keyhostkey- Specified by:
addin 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:HostKeyRepositoryRetuns a list for host keys managed in this repository.- Specified by:
getHostKeyin interfaceHostKeyRepository- See Also:
HostKeyRepository.getHostKey(String host, String type)
-
getHostKey
public HostKey[] getHostKey(java.lang.String host, java.lang.String type)
Description copied from interface:HostKeyRepositoryRetuns a list for host keys managed in this repository.- Specified by:
getHostKeyin interfaceHostKeyRepository- Parameters:
host- a hostname used in searching host keys. Ifnullis 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". Ifnullis given, a key type type will not be ignored.
-
remove
public void remove(java.lang.String host, java.lang.String type)Description copied from interface:HostKeyRepositoryRemoves a host key if there exists mached key withhost,type.- Specified by:
removein interfaceHostKeyRepository- See Also:
HostKeyRepository.remove(String host, String type, byte[] key)
-
remove
public void remove(java.lang.String host, java.lang.String type, byte[] key)Description copied from interface:HostKeyRepositoryRemoves a host key if there exists a matched key withhost,typeandkey.- Specified by:
removein interfaceHostKeyRepository
-
sync
protected void sync() throws java.io.IOException- Throws:
java.io.IOException
-
sync
protected void sync(java.lang.String foo) throws java.io.IOException- Throws:
java.io.IOException
-
dump
void dump(java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
deleteSubString
private java.lang.String deleteSubString(java.lang.String hosts, java.lang.String host)
-
getHMACSHA1
private MAC getHMACSHA1()
-
createHashedHostKey
HostKey createHashedHostKey(java.lang.String host, byte[] key) throws JSchException
- Throws:
JSchException
-
-