com.sshtools.common.hosts
Class AbstractHostKeyVerification
java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.sshtools.common.hosts.AbstractHostKeyVerification
- All Implemented Interfaces:
- HostKeyVerification, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
- Direct Known Subclasses:
- ConsoleHostKeyVerification, DialogHostKeyVerification, Record.myHostKeyValidator
public abstract class AbstractHostKeyVerification
- extends org.xml.sax.helpers.DefaultHandler
- implements HostKeyVerification
- Version:
- $Revision: 1.1 $
- Author:
- $author$
Method Summary |
java.util.Map |
allowedHosts()
|
void |
allowHost(java.lang.String host,
java.lang.String hostKeyFingerprint,
boolean always)
|
private boolean |
checkFingerprint(java.lang.String host,
java.lang.String fingerprint)
|
java.util.List |
deniedHosts()
|
void |
denyHost(java.lang.String host,
boolean always)
|
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qname)
|
boolean |
isHostFileWriteable()
|
abstract void |
onDeniedHost(java.lang.String host)
|
abstract void |
onHostKeyMismatch(java.lang.String host,
java.lang.String allowedHostKey,
java.lang.String actualHostKey)
|
abstract void |
onUnknownHost(java.lang.String host,
java.lang.String hostKeyFingerprint)
|
void |
removeAllowedHost(java.lang.String host)
|
void |
removeDeniedHost(java.lang.String host)
|
void |
saveHostFile()
|
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qname,
org.xml.sax.Attributes attrs)
|
java.lang.String |
toString()
|
boolean |
verifyHost(java.lang.String host,
SshPublicKey pk)
Called by the transport protocol to verify the identity of the server
through the supplied public key. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
defaultHostFile
private static java.lang.String defaultHostFile
log
private static org.apache.commons.logging.Log log
deniedHosts
private java.util.List deniedHosts
allowedHosts
private java.util.Map allowedHosts
hostFile
private java.lang.String hostFile
hostFileWriteable
private boolean hostFileWriteable
expectEndElement
private boolean expectEndElement
currentElement
private java.lang.String currentElement
AbstractHostKeyVerification
public AbstractHostKeyVerification()
throws InvalidHostFileException
- Creates a new AbstractHostKeyVerification object.
- Throws:
InvalidHostFileException
AbstractHostKeyVerification
public AbstractHostKeyVerification(java.lang.String hostFileName)
throws InvalidHostFileException
- Creates a new AbstractHostKeyVerification object.
- Parameters:
hostFileName
-
- Throws:
InvalidHostFileException
startElement
public void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qname,
org.xml.sax.Attributes attrs)
throws org.xml.sax.SAXException
- Specified by:
startElement
in interface org.xml.sax.ContentHandler
- Overrides:
startElement
in class org.xml.sax.helpers.DefaultHandler
- Parameters:
uri
- localName
- qname
- attrs
-
- Throws:
org.xml.sax.SAXException
endElement
public void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qname)
throws org.xml.sax.SAXException
- Specified by:
endElement
in interface org.xml.sax.ContentHandler
- Overrides:
endElement
in class org.xml.sax.helpers.DefaultHandler
- Parameters:
uri
- localName
- qname
-
- Throws:
org.xml.sax.SAXException
isHostFileWriteable
public boolean isHostFileWriteable()
- Returns:
onDeniedHost
public abstract void onDeniedHost(java.lang.String host)
throws TransportProtocolException
- Parameters:
host
-
- Throws:
TransportProtocolException
onHostKeyMismatch
public abstract void onHostKeyMismatch(java.lang.String host,
java.lang.String allowedHostKey,
java.lang.String actualHostKey)
throws TransportProtocolException
- Parameters:
host
- allowedHostKey
- actualHostKey
-
- Throws:
TransportProtocolException
onUnknownHost
public abstract void onUnknownHost(java.lang.String host,
java.lang.String hostKeyFingerprint)
throws TransportProtocolException
- Parameters:
host
- hostKeyFingerprint
-
- Throws:
TransportProtocolException
allowHost
public void allowHost(java.lang.String host,
java.lang.String hostKeyFingerprint,
boolean always)
throws InvalidHostFileException
- Parameters:
host
- hostKeyFingerprint
- always
-
- Throws:
InvalidHostFileException
allowedHosts
public java.util.Map allowedHosts()
- Returns:
deniedHosts
public java.util.List deniedHosts()
- Returns:
removeAllowedHost
public void removeAllowedHost(java.lang.String host)
- Parameters:
host
-
removeDeniedHost
public void removeDeniedHost(java.lang.String host)
- Parameters:
host
-
denyHost
public void denyHost(java.lang.String host,
boolean always)
throws InvalidHostFileException
- Parameters:
host
- always
-
- Throws:
InvalidHostFileException
verifyHost
public boolean verifyHost(java.lang.String host,
SshPublicKey pk)
throws TransportProtocolException
- Description copied from interface:
HostKeyVerification
Called by the transport protocol to verify the identity of the server
through the supplied public key.
- Specified by:
verifyHost
in interface HostKeyVerification
- Parameters:
host
- pk
-
- Returns:
-
- Throws:
TransportProtocolException
checkFingerprint
private boolean checkFingerprint(java.lang.String host,
java.lang.String fingerprint)
saveHostFile
public void saveHostFile()
throws InvalidHostFileException
- Throws:
InvalidHostFileException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
- Returns: