cryptix.pgp
Class KeyGlob

java.lang.Object
  extended bycryptix.pgp.KeyStore
      extended bycryptix.pgp.KeyGlob

public final class KeyGlob
extends KeyStore

Stores all of the key sources known to a program - all public and secret keyrings, and a Web master keyserver. If setKeyServer is not used, the object will not use one.

Can be passed to objects which decrypt and verify PGP messages such as ArmouredMessage.

NB. Keyrings are searched in the order in which they are added. Therefore, always add the most highly trusted keyrings first.

The master keyserver is only consulted if a key is not available locally.


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

$Revision: 1.1.1.1 $

Since:
Cryptix 2.2
Author:
Ian Brown, Jill Baker, Zoran Rajic

Constructor Summary
KeyGlob()
          Initializes an empty KeyGlob.
 
Method Summary
 void addKeyRing(PublicKeyRing publicKeyRing)
          Adds publicKeyRing to the KeyGlob's collection.
 void addKeyRing(SecretKeyRing secretKeyRing)
          Adds secretKeyRing to the KeyGlob's collection.
 PublicKey getKey(EmailAddress address)
          Tries to find a public key for address.
 PublicKey getKey(KeyID id)
          Tries to find a public key for id.
 PublicKey getKey(java.lang.String name)
          Tries to find a public key for name.
 int getKeyTrust(KeyID keyID, boolean publicRings)
          Gets the trust value for a given key ID.
 SecretKey getSecretKey(KeyID id, Passphrase passphrase)
          Tries to find a secret key for id, and decrypt it with passphrase.
 SecretKey getSecretKey(java.lang.String name, Passphrase passphrase)
          Tries to find a secret key for name, and decrypt it with passphrase.
 java.lang.String getUserName(KeyID keyID)
          Returns the name of a user whose key has ID keyID.
 void setKeyServer(KeyClient client)
          Gives KeyGlob a keyclient object that it can use to fetch keys remotely.
 
Methods inherited from class cryptix.pgp.KeyStore
checkSignature, checkSignature, checkSignature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyGlob

public KeyGlob()
Initializes an empty KeyGlob. Use addKeyRing and setKeyServer to fill it up.

Method Detail

addKeyRing

public void addKeyRing(PublicKeyRing publicKeyRing)
Adds publicKeyRing to the KeyGlob's collection.


addKeyRing

public void addKeyRing(SecretKeyRing secretKeyRing)
Adds secretKeyRing to the KeyGlob's collection.

By allowing more than one secret keyring, users can keep a standard secret key available, and have a high-security key stored on a floppy disk which applications only access transparently through this class when it's needed.


setKeyServer

public void setKeyServer(KeyClient client)
                  throws java.io.IOException,
                         java.net.UnknownHostException
Gives KeyGlob a keyclient object that it can use to fetch keys remotely. This will be searched for public keys if they are not available locally.

Parameters:
client - an instantiated KeyClient subclass object
Throws:
java.io.IOException - if there was an I/O error
java.net.UnknownHostException - if the public key server was unreachable

getKeyTrust

public int getKeyTrust(KeyID keyID,
                       boolean publicRings)
Gets the trust value for a given key ID.

Parameters:
keyID - the key ID you are interested in
publicRings - search public rings (true), or secret rings (false)
Returns:
trust value, or -1 if key not present

getKey

public PublicKey getKey(java.lang.String name)
                 throws java.io.IOException
Tries to find a public key for name.

Specified by:
getKey in class KeyStore
Parameters:
name - the name of the user
Returns:
their public key, or null if one can't be found
Throws:
java.io.IOException - if there was an I/O error

getKey

public PublicKey getKey(KeyID id)
                 throws java.io.IOException
Tries to find a public key for id.

Specified by:
getKey in class KeyStore
Parameters:
id - the key ID of the user (the low 8 bits of their key pair's public modulus)
Returns:
their public key, or null if one can't be found
Throws:
java.io.IOException - if there was an I/O error

getKey

public PublicKey getKey(EmailAddress address)
                 throws java.io.IOException
Tries to find a public key for address.

Parameters:
address - the e-mail address of the user
Returns:
their public key, or null if one can't be found
Throws:
java.io.IOException - if there was an I/O error

getSecretKey

public SecretKey getSecretKey(java.lang.String name,
                              Passphrase passphrase)
                       throws java.io.IOException,
                              DecryptException
Tries to find a secret key for name, and decrypt it with passphrase.

Parameters:
name - the e-mail address of the user
passphrase - the passphrase protecting their secret key
Returns:
their secret key, or null if one can't be found
Throws:
java.io.IOException - if there was an I/O error
DecryptException - if the secret key could not be decrypted

getSecretKey

public SecretKey getSecretKey(KeyID id,
                              Passphrase passphrase)
                       throws java.io.IOException,
                              DecryptException
Tries to find a secret key for id, and decrypt it with passphrase.

Parameters:
id - the key ID of the user's key
passphrase - the passphrase protecting their secret key
Returns:
their secret key, or null if one can't be found
Throws:
java.io.IOException - if there was an I/O error
DecryptException - if the secret key could not be decrypted

getUserName

public java.lang.String getUserName(KeyID keyID)
Returns the name of a user whose key has ID keyID.

Only checks local keyrings.