org.bouncycastle.openpgp
Class PGPPublicKeyRingCollection
java.lang.Object
org.bouncycastle.openpgp.PGPPublicKeyRingCollection
public class PGPPublicKeyRingCollection
extends java.lang.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.
PGPPublicKeyRingCollection
public PGPPublicKeyRingCollection(Collection collection)
throws IOException,
PGPException
PGPPublicKeyRingCollection
public PGPPublicKeyRingCollection(InputStream in)
throws IOException,
PGPException
PGPPublicKeyRingCollection
public PGPPublicKeyRingCollection(byte[] encoding)
throws IOException,
PGPException
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.
ringCollection
- the collection the ring to be added to.publicKeyRing
- the key ring to be added.
- a new collection merging the current one with the passed in ring.
encode
public void encode(OutputStream outStream)
throws IOException
getEncoded
public byte[] getEncoded()
throws IOException
getKeyRings
public Iterator getKeyRings()
return the public key rings making up this collection.
getKeyRings
public Iterator getKeyRings(String userID)
throws PGPException
Return an iterator of the key rings associated with the passed in userID.
userID
- the user ID to be matched.
- an iterator (possibly empty) of key rings which matched.
getKeyRings
public Iterator getKeyRings(String userID,
boolean matchPartial)
throws PGPException
Return an iterator of the key rings associated with the passed in userID.
userID
- the user ID to be matched.matchPartial
- if true userID need only be a substring of an actual ID string to match.
- an iterator (possibly empty) of key rings which matched.
getPublicKey
public PGPPublicKey getPublicKey(long keyID)
throws PGPException
Return the PGP public key associated with the given key id.
getPublicKeyRing
public PGPPublicKeyRing getPublicKeyRing(long keyID)
throws PGPException
Return the public key ring which contains the key referred to by keyID.
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.
ringCollection
- the collection the ring to be removed from.publicKeyRing
- the key ring to be removed.
- a new collection not containing the passed in ring.
size
public int size()
Return the number of rings in this collection.