org.logi.crypto.keys
Class KeyRing

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.keys.KeyRing
All Implemented Interfaces:
KeySource

public class KeyRing
extends Crypto
implements KeySource

This implementation of the KeySource interface stores keys in a hash-table. It can be converted to and from a CDS for storage.

A database key-source would be more appropriate for large collections of keys, but hasn't been written yet. An interface to a key-server would be more appropriate for really huge key collections but will have to wait even longer.

The CDS for a KeyRing object is KeyRing(k1,k2,...,kn) with n>=0 and each ki the CDS for a KeyRecord or Key object.

Author:
Logi Ragnarsson (logir@logi.org)
See Also:
Key, KeyRecord

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
KeyRing()
          Create empty key ring.
 
Method Summary
 KeyRecord byFingerprint(Fingerprint fingerprint)
          Retreive the key with the given fingerprint.
 void insert(Key k)
          Insert the Key k into the KeyRing.
 void insert(KeyRecord kc)
          Insert the KeyRecord k into the KeyRing.
static KeyRing parseCDS(java.lang.String arg)
          If "KeyRing( key )" is a valid CDS for a KeyRing, then KeyRing.parseCDS(key) will return the described KeyRing object.
 java.lang.String toString()
          Return a CDS for this KeyRing.
 
Methods inherited from class org.logi.crypto.Crypto
binString, binString, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, readBlock, readInt, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyRing

public KeyRing()
Create empty key ring.
Method Detail

parseCDS

public static KeyRing parseCDS(java.lang.String arg)
                        throws InvalidCDSException
If "KeyRing( key )" is a valid CDS for a KeyRing, then KeyRing.parseCDS(key) will return the described KeyRing object.

A valid CDS can be created by calling the KeyRing.toString() method.

Throws:
InvalidCDSException - if the CDS is malformed.
See Also:
Crypto.fromString(String)

toString

public java.lang.String toString()
Return a CDS for this KeyRing.
Overrides:
toString in class java.lang.Object

insert

public void insert(Key k)
Insert the Key k into the KeyRing. It will be wrapped in a KeyRecord containing empty strings and no certificates.

insert

public void insert(KeyRecord kc)
Insert the KeyRecord k into the KeyRing.

byFingerprint

public KeyRecord byFingerprint(Fingerprint fingerprint)
Retreive the key with the given fingerprint. If it is not found in the key-source, null is returned. fingerprint must be created with the same algorithm as the the Key object uses, which will be SHA1 for the Key classes included with Crypto.
Specified by:
byFingerprint in interface KeySource


Copyright 1997-2000 Logi Ragnarsson