org.bouncycastle.openpgp

Class PGPPublicKeyRingCollection

public class PGPPublicKeyRingCollection extends Object

Often a PGP key ring file is made up of a succession of master/sub-key key rings. If you want to read an entire public key file in one hit this is the class for you.
Constructor Summary
PGPPublicKeyRingCollection(byte[] encoding)
PGPPublicKeyRingCollection(InputStream in)
Build a PGPPublicKeyRingCollection from the passed in input stream.
PGPPublicKeyRingCollection(Collection collection)
Method Summary
static PGPPublicKeyRingCollectionaddPublicKeyRing(PGPPublicKeyRingCollection ringCollection, PGPPublicKeyRing publicKeyRing)
Return a new collection object containing the contents of the passed in collection and the passed in public key ring.
voidencode(OutputStream outStream)
byte[]getEncoded()
IteratorgetKeyRings()
return the public key rings making up this collection.
IteratorgetKeyRings(String userID, boolean matchPartial)
Return an iterator of the key rings associated with the passed in userID.
IteratorgetKeyRings(String userID)
Return an iterator of the key rings associated with the passed in userID.
PGPPublicKeygetPublicKey(long keyID)
Return the PGP public key associated with the given key id.
PGPPublicKeyRinggetPublicKeyRing(long keyID)
Return the public key ring which contains the key referred to by keyID.
static PGPPublicKeyRingCollectionremovePublicKeyRing(PGPPublicKeyRingCollection ringCollection, PGPPublicKeyRing publicKeyRing)
Return a new collection object containing the contents of this collection with the passed in public key ring removed.
intsize()
Return the number of rings in this collection.

Constructor Detail

PGPPublicKeyRingCollection

public PGPPublicKeyRingCollection(byte[] encoding)

PGPPublicKeyRingCollection

public PGPPublicKeyRingCollection(InputStream in)
Build a PGPPublicKeyRingCollection from the passed in input stream.

Parameters: in input stream containing data

Throws: IOException if a problem parsinh the base stream occurs PGPException if an object is encountered which isn't a PGPPublicKeyRing

PGPPublicKeyRingCollection

public PGPPublicKeyRingCollection(Collection collection)

Method Detail

addPublicKeyRing

public static PGPPublicKeyRingCollection addPublicKeyRing(PGPPublicKeyRingCollection ringCollection, PGPPublicKeyRing publicKeyRing)
Return a new collection object containing the contents of the passed in collection and the passed in public key ring.

Parameters: ringCollection the collection the ring to be added to. publicKeyRing the key ring to be added.

Returns: a new collection merging the current one with the passed in ring.

Throws: IllegalArgumentException if the keyID for the passed in ring is already present.

encode

public void encode(OutputStream outStream)

getEncoded

public byte[] getEncoded()

getKeyRings

public Iterator getKeyRings()
return the public key rings making up this collection.

getKeyRings

public Iterator getKeyRings(String userID, boolean matchPartial)
Return an iterator of the key rings associated with the passed in userID.

Parameters: userID the user ID to be matched. matchPartial if true userID need only be a substring of an actual ID string to match.

Returns: an iterator (possibly empty) of key rings which matched.

Throws: PGPException

getKeyRings

public Iterator getKeyRings(String userID)
Return an iterator of the key rings associated with the passed in userID.

Parameters: userID the user ID to be matched.

Returns: an iterator (possibly empty) of key rings which matched.

Throws: PGPException

getPublicKey

public PGPPublicKey getPublicKey(long keyID)
Return the PGP public key associated with the given key id.

Parameters: keyID

Returns: the PGP public key

Throws: PGPException

getPublicKeyRing

public PGPPublicKeyRing getPublicKeyRing(long keyID)
Return the public key ring which contains the key referred to by keyID.

Parameters: keyID

Returns: the public key ring

Throws: PGPException

removePublicKeyRing

public static PGPPublicKeyRingCollection removePublicKeyRing(PGPPublicKeyRingCollection ringCollection, PGPPublicKeyRing publicKeyRing)
Return a new collection object containing the contents of this collection with the passed in public key ring removed.

Parameters: ringCollection the collection the ring to be removed from. publicKeyRing the key ring to be removed.

Returns: a new collection not containing the passed in ring.

Throws: IllegalArgumentException if the keyID for the passed in ring not present.

size

public int size()
Return the number of rings in this collection.

Returns: size of the collection