|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.enterprisedt.net.ftp.ssh.SSHFTPValidator
public class SSHFTPValidator
Provides server validation services for SSHFTPClient.
By default, SSHFTPClient uses an instance of this class for all
its validation functions. It provides the following functions:
SCPClient.setValidator(SSHFTPValidator).
| Constructor Summary | |
|---|---|
SSHFTPValidator()
Default constructor. |
|
| Method Summary | |
|---|---|
void |
addKnownHost(java.lang.String hostName,
java.io.InputStream publicKeyStream)
Adds the given host (and associated key data supplied in the inputstream) to the list of known hosts. |
void |
addKnownHost(java.lang.String hostName,
java.lang.String publicKeyFile)
Adds the given host (and associated key-file) to the list of known hosts. |
SSHFTPPublicKey |
getHostPublicKey()
Provides access to the current remote host's public key. |
java.util.Hashtable |
getKnownHosts()
Returns the known hosts and their public keys. |
boolean |
isHostValidationEnabled()
Returns true if host validation is enabled. |
void |
loadKnownHosts(java.io.InputStream hostsStream)
Loads a list of hosts and their associated public keys from the given InputStream. |
void |
loadKnownHosts(java.lang.String hostsFileName)
Loads a list of hosts and their associated public keys from the given file. |
void |
removeAllKnownHosts()
Clears all known hosts. |
void |
removeKnownHost(java.lang.String hostName)
Remove the given host from the list of known hosts. |
void |
setHostValidationEnabled(boolean hostValidationEnabled)
Sets the flag controlling whether or not hosts will be validated. |
protected boolean |
validate(java.lang.String hostSpecifier,
SSHFTPPublicKey publicKey,
boolean hostKnown)
|
protected boolean |
validate(java.lang.String hostSpecifier,
java.lang.String fingerPrint,
boolean hostKnown)
Deprecated. Use validate(String, SSHFTPPublicKey, boolean). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SSHFTPValidator()
| Method Detail |
|---|
public void loadKnownHosts(java.lang.String hostsFileName)
throws java.io.FileNotFoundException,
java.io.IOException
jackspc ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIE...If there are more than one host using a given key the host-name may be replaced by a comma-separated list of host-names. IP addresses may be used. Wildcards may not be used.
Note that this method does not clear any previous settings.
hostsFileName - Name of the file containing the hosts.
java.io.FileNotFoundException - Thrown if the file could not be found.
java.io.IOException - Thrown if the file could not be read.
public void loadKnownHosts(java.io.InputStream hostsStream)
throws java.io.IOException
InputStream. The format of the content
of the stream is similar to
that used in OpenSSH. Each line contains the name of a host, the type of
key it has, and its key (in base-64 printable form). For example:
jackspc ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIE...If there are more than one host using a given key the host-name may be replaced by a comma-separated list of host-names. IP addresses may be used. Wildcards may not be used.
Note that this method does not clear any previous settings.
hostsStream - Stream containing the hosts.
java.io.FileNotFoundException - Thrown if the file could not be found.
java.io.IOException - Thrown if the file could not be read.
public void addKnownHost(java.lang.String hostName,
java.lang.String publicKeyFile)
throws java.io.IOException,
com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException
hostName - Name of the hostpublicKeyFile - Name of the file containing the host's public key.
java.io.IOException - Thrown if there was a problem reading the key-file.
com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException - Thrown if the key was not valid.
public void addKnownHost(java.lang.String hostName,
java.io.InputStream publicKeyStream)
throws java.io.IOException,
com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException
hostName - Name of the hostpublicKeyStream - stream containing the host's public key.
java.io.IOException - Thrown if there was a problem reading the stream.
com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException - Thrown if the key was not valid.public void removeKnownHost(java.lang.String hostName)
hostName - Name of the host.public void removeAllKnownHosts()
protected boolean validate(java.lang.String hostSpecifier,
java.lang.String fingerPrint,
boolean hostKnown)
validate(String, SSHFTPPublicKey, boolean).
false.
hostSpecifier - Host-name and IP address separated by a comma.fingerPrint - Human-readable form of the host's fingerprint.hostKnown - true if there was an entry for the host
but not with the required algorithm (note that several algorithms may be
defined for each host).
true if the host is valid.
protected boolean validate(java.lang.String hostSpecifier,
SSHFTPPublicKey publicKey,
boolean hostKnown)
public boolean isHostValidationEnabled()
true if host validation is enabled.
true if host validation is enabled.public void setHostValidationEnabled(boolean hostValidationEnabled)
hostValidationEnabled - New valid of the flag.public java.util.Hashtable getKnownHosts()
public SSHFTPPublicKey getHostPublicKey()
null before the first connection attempt is made.
This method is particularly useful if the server's public key is not
available by other means. In such cases a connection attempt should be made
without adding any known hosts. This attempt will fail, but getHostPublicKey()
may be used afterwards to obtain the public key. The
SSHFTPPublicKey.write(OutputStream,int) method may be used to write it
to a file for use in subsequent connections.
Note that null may be returned after a connection attempt is made if the attempt failed before public keys were exchanged between the client and the server.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||