Java Doc for KnownHosts.java in  » Net » Ganymed-SSH-2 » ch » ethz » ssh2 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Ganymed SSH 2 » ch.ethz.ssh2 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   ch.ethz.ssh2.KnownHosts

KnownHosts
public class KnownHosts (Code)
The KnownHosts class is a handy tool to verify received server hostkeys based on the information in known_hosts files (the ones used by OpenSSH).

It offers basically an in-memory database for known_hosts entries, as well as some helper functions. Entries from a known_hosts file can be loaded at construction time. It is also possible to add more keys later (e.g., one can parse different known_hosts files).

It is a thread safe implementation, therefore, you need only to instantiate one KnownHosts for your whole application.
author:
   Christian Plattner, plattner@inf.ethz.ch
version:
   $Id: KnownHosts.java,v 1.5 2006/07/30 21:59:29 cplattne Exp $



Field Summary
final public static  intHOSTKEY_HAS_CHANGED
    
final public static  intHOSTKEY_IS_NEW
    
final public static  intHOSTKEY_IS_OK
    

Constructor Summary
public  KnownHosts()
    
public  KnownHosts(char[] knownHostsData)
    
public  KnownHosts(File knownHosts)
    

Method Summary
public  voidaddHostkey(String hostnames, String serverHostKeyAlgorithm, byte[] serverHostKey)
     Adds a single public key entry to the database.
final public static  voidaddHostkeyToFile(File knownHosts, String[] hostnames, String serverHostKeyAlgorithm, byte[] serverHostKey)
     Adds a single public key entry to the a known_hosts file. This method is designed to be used in a ServerHostKeyVerifier .
Parameters:
  knownHosts - the file where the publickey entry will be appended.
Parameters:
  hostnames - a list of hostname patterns - at least one most be specified.
public  voidaddHostkeys(char[] knownHostsData)
     Parses the given known_hosts data and adds entries to the database.
public  voidaddHostkeys(File knownHosts)
     Parses the given known_hosts file and adds entries to the database.
final public static  StringcreateBubblebabbleFingerprint(String keytype, byte[] publickey)
     Convert a ssh2 key-blob into a human readable bubblebabble fingerprint.
final public static  StringcreateHashedHostname(String hostname)
     Generate the hashed representation of the given hostname.
final public static  StringcreateHexFingerprint(String keytype, byte[] publickey)
     Convert a ssh2 key-blob into a human readable hex fingerprint.
public  String[]getPreferredServerHostkeyAlgorithmOrder(String hostname)
     Try to find the preferred order of hostkey algorithms for the given hostname. Based on the type of hostkey that is present in the internal database (i.e., either ssh-rsa or ssh-dss) an ordered list of hostkey algorithms is returned which can be passed to Connection.setServerHostKeyAlgorithms.
public  intverifyHostkey(String hostname, String serverHostKeyAlgorithm, byte[] serverHostKey)
     Checks the internal hostkey database for the given hostkey.

Field Detail
HOSTKEY_HAS_CHANGED
final public static int HOSTKEY_HAS_CHANGED(Code)



HOSTKEY_IS_NEW
final public static int HOSTKEY_IS_NEW(Code)



HOSTKEY_IS_OK
final public static int HOSTKEY_IS_OK(Code)




Constructor Detail
KnownHosts
public KnownHosts()(Code)



KnownHosts
public KnownHosts(char[] knownHostsData) throws IOException(Code)



KnownHosts
public KnownHosts(File knownHosts) throws IOException(Code)




Method Detail
addHostkey
public void addHostkey(String hostnames, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException(Code)
Adds a single public key entry to the database. Note: this will NOT add the public key to any physical file (e.g., "~/.ssh/known_hosts") - use addHostkeyToFile() for that purpose. This method is designed to be used in a ServerHostKeyVerifier .
Parameters:
  hostnames - a list of hostname patterns - at least one most be specified. Check out theOpenSSH sshd man page for a description of the pattern matching algorithm.
Parameters:
  serverHostKeyAlgorithm - as passed to the ServerHostKeyVerifier.
Parameters:
  serverHostKey - as passed to the ServerHostKeyVerifier.
throws:
  IOException -



addHostkeyToFile
final public static void addHostkeyToFile(File knownHosts, String[] hostnames, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException(Code)
Adds a single public key entry to the a known_hosts file. This method is designed to be used in a ServerHostKeyVerifier .
Parameters:
  knownHosts - the file where the publickey entry will be appended.
Parameters:
  hostnames - a list of hostname patterns - at least one most be specified. Check out theOpenSSH sshd man page for a description of the pattern matching algorithm.
Parameters:
  serverHostKeyAlgorithm - as passed to the ServerHostKeyVerifier.
Parameters:
  serverHostKey - as passed to the ServerHostKeyVerifier.
throws:
  IOException -



addHostkeys
public void addHostkeys(char[] knownHostsData) throws IOException(Code)
Parses the given known_hosts data and adds entries to the database.
Parameters:
  knownHostsData -
throws:
  IOException -



addHostkeys
public void addHostkeys(File knownHosts) throws IOException(Code)
Parses the given known_hosts file and adds entries to the database.
Parameters:
  knownHosts -
throws:
  IOException -



createBubblebabbleFingerprint
final public static String createBubblebabbleFingerprint(String keytype, byte[] publickey)(Code)
Convert a ssh2 key-blob into a human readable bubblebabble fingerprint. The used bubblebabble algorithm (taken from OpenSSH) generates fingerprints that are easier to remember for humans.

Example fingerprint: xofoc-bubuz-cazin-zufyl-pivuk-biduk-tacib-pybur-gonar-hotat-lyxux.
Parameters:
  keytype - either "ssh-rsa" or "ssh-dss"
Parameters:
  publickey - key data Bubblebabble fingerprint




createHashedHostname
final public static String createHashedHostname(String hostname)(Code)
Generate the hashed representation of the given hostname. Useful for adding entries with hashed hostnames to a known_hosts file. (see -H option of OpenSSH key-gen).
Parameters:
  hostname - the hashed representation, e.g., "|1|cDhrv7zwEUV3k71CEPHnhHZezhA=|Xo+2y6rUXo2OIWRAYhBOIijbJMA="



createHexFingerprint
final public static String createHexFingerprint(String keytype, byte[] publickey)(Code)
Convert a ssh2 key-blob into a human readable hex fingerprint. Generated fingerprints are identical to those generated by OpenSSH.

Example fingerprint: d0:cb:76:19:99:5a:03:fc:73:10:70:93:f2:44:63:47.
Parameters:
  keytype - either "ssh-rsa" or "ssh-dss"
Parameters:
  publickey - key blob Hex fingerprint




getPreferredServerHostkeyAlgorithmOrder
public String[] getPreferredServerHostkeyAlgorithmOrder(String hostname)(Code)
Try to find the preferred order of hostkey algorithms for the given hostname. Based on the type of hostkey that is present in the internal database (i.e., either ssh-rsa or ssh-dss) an ordered list of hostkey algorithms is returned which can be passed to Connection.setServerHostKeyAlgorithms.
Parameters:
  hostname - null if no key for the given hostname is present orthere are keys of multiple types present for the given hostname. Otherwise,an array with hostkey algorithms is returned (i.e., an array of length 2).



verifyHostkey
public int verifyHostkey(String hostname, String serverHostKeyAlgorithm, byte[] serverHostKey) throws IOException(Code)
Checks the internal hostkey database for the given hostkey. If no matching key can be found, then the hostname is resolved to an IP address and the search is repeated using that IP address.
Parameters:
  hostname - the server's hostname, will be matched with all hostname patterns
Parameters:
  serverHostKeyAlgorithm - type of hostkey, either ssh-rsa or ssh-dss
Parameters:
  serverHostKey - the key blob
  • HOSTKEY_IS_OK: the given hostkey matches an entry for the given hostname
  • HOSTKEY_IS_NEW: no entries found for this hostname and this type of hostkey
  • HOSTKEY_HAS_CHANGED: hostname is known, but with another key of the same type(man-in-the-middle attack?)

throws:
  IOException - if the supplied key blob cannot be parsed or does not match the given hostkey type.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.