cryptix.pgp
Class KeyRing

java.lang.Object
  extended bycryptix.pgp.KeyStore
      extended bycryptix.pgp.KeyRing
Direct Known Subclasses:
KeyRingTest, PublicKeyRing, SecretKeyRing

public abstract class KeyRing
extends KeyStore

KeyRing is an abstract superclass for keyring objects - stores of keys (public and private) held in a file. PublicKeyRing, KeyCache and SecretKeyRing implement the specific behaviour of these different kinds of keyring files.

Note that a keyring is not automatically written out when it is destroyed. The application must call write() itself if it has added keys that it wishes to keep.

KeyRing is unlikely to be useful for any other subclasses. If you wish to implement a general key retrieval class, use KeyStore instead. If you wish to add file-specific behaviour, use PublicKeyRing or SecretKeyRing.

Future changes

A remove() function may be added.

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.1.1.1 $

Since:
Cryptix 2.2 or earlier
Author:
Systemics Ltd, Ian Brown, Jill Baker
See Also:
PublicKeyRing, KeyCache, SecretKeyRing

Field Summary
protected  java.util.Hashtable addresses
           
protected  java.util.Hashtable entriesById
           
protected  java.util.Hashtable users
           
 
Constructor Summary
protected KeyRing()
          Creates an empty keyring object.
protected KeyRing(java.io.InputStream in)
          Creates a new keyring object from in.
protected KeyRing(java.lang.String filename)
          Deprecated.  
 
Method Summary
 void add(KeyRingEntry entry)
          Adds a key to this keyring.
 boolean checkSignatures()
          Checks the signatures assuming all the keys are in this ring.
 boolean checkSignatures(KeyStore store)
          Checks the signatures assuming that the KeyStore contains all the necessary keys.
 void dump(java.io.PrintStream out)
          Debug dump of key ring.
 java.lang.String[] getFullNameList(KeyID keyID)
          Gets a list of all the names on the key with ID keyID.
 java.lang.String[] getFullUserNameList()
          Gets a list of all the usernames of keys on this keyring.
protected  PublicKey getIfBegins(java.util.Enumeration e, java.lang.String username)
           
 int getKeyTrust(KeyID keyId)
          How much is the key with ID keyId trusted by this user?
protected  PublicKey getPublicKey(EmailAddress address)
           
protected  PublicKey getPublicKey(KeyID id)
           
protected  SecretKey getSecretKey(EmailAddress address, Passphrase passphrase)
           
protected  SecretKey getSecretKey(KeyID id, Passphrase passphrase)
           
 java.lang.String getUserName(KeyID keyID)
          Returns the primary name of the user who owns the key referenced by keyID.
protected abstract  void init(PacketInputStream reader)
          Subclasses should override this method to read entries from an InputStream.
 void list(java.io.PrintStream out)
          Debug list of signatures etc.
 void write(java.io.OutputStream outputStream)
          Writes out all KeyRingEntries contained in this keyring to outputStream.
 
Methods inherited from class cryptix.pgp.KeyStore
checkSignature, checkSignature, checkSignature, getKey, getKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

users

protected java.util.Hashtable users

addresses

protected java.util.Hashtable addresses

entriesById

protected java.util.Hashtable entriesById
Constructor Detail

KeyRing

protected KeyRing()
Creates an empty keyring object.


KeyRing

protected KeyRing(java.io.InputStream in)
           throws java.io.IOException
Creates a new keyring object from in.

Throws:
java.io.IOException - if there was an I/O error

KeyRing

protected KeyRing(java.lang.String filename)
           throws java.io.FileNotFoundException,
                  java.io.IOException
Deprecated.  

This constructor used to create a new keyring object from the file filename. It is no longer supported for security reasons.

Throws:
java.lang.NoSuchMethodError - always thrown.
java.io.FileNotFoundException
java.io.IOException
Method Detail

init

protected abstract void init(PacketInputStream reader)
                      throws java.io.IOException
Subclasses should override this method to read entries from an InputStream.

Throws:
java.io.IOException

getUserName

public final java.lang.String getUserName(KeyID keyID)
Returns the primary name of the user who owns the key referenced by keyID.

If their key is not available, the keyID is returned as a String. This mimics PGP's behaviour.


add

public final void add(KeyRingEntry entry)
               throws FormatException
Adds a key to this keyring.

You can't just add a Certificate - you need at least a UserId and KeyRingTrust packet, and possibly signatures and further UserIds as well.

KeyRingEntry contains all of this.

Throws:
FormatException

getFullNameList

public final java.lang.String[] getFullNameList(KeyID keyID)
Gets a list of all the names on the key with ID keyID.


getFullUserNameList

public final java.lang.String[] getFullUserNameList()
Gets a list of all the usernames of keys on this keyring.


getPublicKey

protected final PublicKey getPublicKey(KeyID id)

getPublicKey

protected final PublicKey getPublicKey(EmailAddress address)

getSecretKey

protected final SecretKey getSecretKey(KeyID id,
                                       Passphrase passphrase)
                                throws DecryptException
Throws:
DecryptException

getSecretKey

protected final SecretKey getSecretKey(EmailAddress address,
                                       Passphrase passphrase)
                                throws DecryptException
Throws:
DecryptException

getIfBegins

protected final PublicKey getIfBegins(java.util.Enumeration e,
                                      java.lang.String username)
                               throws java.io.IOException
Throws:
java.io.IOException

write

public void write(java.io.OutputStream outputStream)
           throws java.io.IOException
Writes out all KeyRingEntries contained in this keyring to outputStream.

Throws:
java.io.IOException

checkSignatures

public boolean checkSignatures()
Checks the signatures assuming all the keys are in this ring.


checkSignatures

public boolean checkSignatures(KeyStore store)
Checks the signatures assuming that the KeyStore contains all the necessary keys.


dump

public final void dump(java.io.PrintStream out)
Debug dump of key ring.


list

public final void list(java.io.PrintStream out)
Debug list of signatures etc.


getKeyTrust

public int getKeyTrust(KeyID keyId)
How much is the key with ID keyId trusted by this user?