org.bouncycastle.openpgp

Class PGPPublicKeyRing


public class PGPPublicKeyRing
extends java.lang.Object

general class to hold a collection of PGP Public Keys.

Constructor Summary

PGPPublicKeyRing(InputStream in)
PGPPublicKeyRing(byte[] encoding)

Method Summary

void
encode(OutputStream outStream)
byte[]
getEncoded()
PGPPublicKey
getPublicKey()
Return the first public key in the ring.
PGPPublicKey
getPublicKey(long keyID)
Return the public key refered to by the passed in keyID if it is present.
Iterator
getPublicKeys()
Return an iterator containing all the public keys.
static PGPPublicKeyRing
insertPublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)
Returns a new key ring with the publick key passed in either added or replacing an existing one.
static PGPPublicKeyRing
removePublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)
Returns a new key ring with the publick key passed in removed from the key ring.

Constructor Details

PGPPublicKeyRing

public PGPPublicKeyRing(InputStream in)
            throws IOException


PGPPublicKeyRing

public PGPPublicKeyRing(byte[] encoding)
            throws IOException

Method Details

encode

public void encode(OutputStream outStream)
            throws IOException


getEncoded

public byte[] getEncoded()
            throws IOException


getPublicKey

public PGPPublicKey getPublicKey()
Return the first public key in the ring.

Returns:
PGPPublicKey


getPublicKey

public PGPPublicKey getPublicKey(long keyID)
            throws PGPException
Return the public key refered to by the passed in keyID if it is present.

Parameters:
keyID -

Returns:
PGPPublicKey

Throws:
PGPException -


getPublicKeys

public Iterator getPublicKeys()
Return an iterator containing all the public keys.

Returns:
Iterator


insertPublicKey

public static PGPPublicKeyRing insertPublicKey(PGPPublicKeyRing pubRing,
                                               PGPPublicKey pubKey)
Returns a new key ring with the publick key passed in either added or replacing an existing one.

Parameters:
pubRing - the public key ring to be modified
pubKey - the public key to be added.

Returns:
a new keyRing


removePublicKey

public static PGPPublicKeyRing removePublicKey(PGPPublicKeyRing pubRing,
                                               PGPPublicKey pubKey)
Returns a new key ring with the publick key passed in removed from the key ring.

Parameters:
pubRing - the public key ring to be modified
pubKey - the public key to be added.

Returns:
a new keyRing, null if pubKey is not found.