com.sshtools.j2ssh.transport
Class HostKeyVerification

java.lang.Object
  |
  +--com.sshtools.j2ssh.transport.HostKeyVerification

public abstract class HostKeyVerification
extends java.lang.Object

Implement this class to define specific handling of server host authorization events. The default hosts file is hosts.xml and should be located in JSSH_HOME.

Version:
1.0
Author:
Lee David Painter ( lee@sshtools.com )

Constructor Summary
HostKeyVerification()
           Constructs the object loading the default hosts file.
HostKeyVerification(java.lang.String hostFileName)
           Constructs the object loading the host file specified.
 
Method Summary
 void allowHost(java.lang.String host, java.lang.String hostKeyFingerprint, boolean always)
           Allows the host access if the host provides the host key specified.
 void denyHost(java.lang.String host, boolean always)
           Denys the host access.
abstract  void onDeniedHost(java.lang.String host)
           Abstract method called by the framework when a connection has been made to a denied host.
abstract  void onHostKeyMismatch(java.lang.String host, java.lang.String allowedHostKey, java.lang.String actualHostKey)
           Abstract method called by the framework when a host key has been supplied that does not match the host key recorded in the host file.
abstract  void onUnknownHost(java.lang.String host, java.lang.String hostKeyFingerprint)
           Abstract method called by the framework when a host key has been supplied that is not currently recorded in the hosts file.
 boolean verifyHost(java.lang.String host, java.lang.String fingerprint)
           Called by the framework to verify a host key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostKeyVerification

public HostKeyVerification()
                    throws InvalidHostFileException

Constructs the object loading the default hosts file.

Throws:
InvalidHostFileException - Description of the Exception

HostKeyVerification

public HostKeyVerification(java.lang.String hostFileName)
                    throws InvalidHostFileException

Constructs the object loading the host file specified.

Parameters:
hostFileName -
Throws:
InvalidHostFileException - Description of the Exception
Method Detail

onUnknownHost

public abstract void onUnknownHost(java.lang.String host,
                                   java.lang.String hostKeyFingerprint)

Abstract method called by the framework when a host key has been supplied that is not currently recorded in the hosts file.

Parameters:
host - The name of the host.
hostKeyFingerprint - The fingerprint of the host key supplied.

onHostKeyMismatch

public abstract void onHostKeyMismatch(java.lang.String host,
                                       java.lang.String allowedHostKey,
                                       java.lang.String actualHostKey)

Abstract method called by the framework when a host key has been supplied that does not match the host key recorded in the host file.

Parameters:
host - The name of the host.
allowedHostKey - The host key currently allowed.
actualHostKey - The host key provided.

onDeniedHost

public abstract void onDeniedHost(java.lang.String host)

Abstract method called by the framework when a connection has been made to a denied host.

NOTE: This currently does not supply the fingerprint of the denied host for a reason; if the host has been denied, most probably by an administrator then we should not be providing the host key for the user to subsequently allow the host.

Parameters:
host - The name of the denied host.

allowHost

public void allowHost(java.lang.String host,
                      java.lang.String hostKeyFingerprint,
                      boolean always)
               throws InvalidHostFileException

Allows the host access if the host provides the host key specified.

Parameters:
host - The name of the host.
hostKeyFingerprint - The fingerprint of the acceptable host key.
always - Specifies whether to always allow the host access (true) or only allow access this time.
Throws:
InvalidHostFileException - Description of the Exception

denyHost

public void denyHost(java.lang.String host,
                     boolean always)
              throws InvalidHostFileException

Denys the host access.

Parameters:
host - The name of the host.
always - Specifies whether to always deny the specified host (true) or just deny the host acceess this time (false)
Throws:
InvalidHostFileException - Description of the Exception

verifyHost

public boolean verifyHost(java.lang.String host,
                          java.lang.String fingerprint)

Called by the framework to verify a host key

Parameters:
host - The name of the host
fingerprint - The fingerprint of the host key
Returns:
The result of the host key verification


Copyright © 2002 Sshtools.com. All Rights Reserved.