public class PGPPublicKeyRing extends PGPKeyRing implements org.bouncycastle.util.Iterable<PGPPublicKey>
Often PGP keyring files consist of multiple master keys, if you are trying to process or construct one of these you should use the PGPPublicKeyRingCollection class.
Constructor and Description |
---|
PGPPublicKeyRing(byte[] encoding,
KeyFingerPrintCalculator fingerPrintCalculator) |
PGPPublicKeyRing(java.io.InputStream in,
KeyFingerPrintCalculator fingerPrintCalculator) |
PGPPublicKeyRing(java.util.List<PGPPublicKey> pubKeys)
Base constructor from a list of keys representing a public key ring (a master key and its
associated sub-keys).
|
Modifier and Type | Method and Description |
---|---|
void |
encode(java.io.OutputStream outStream) |
void |
encode(java.io.OutputStream outStream,
boolean forTransfer)
Encode the key ring to outStream, with trust packets stripped out if forTransfer is true.
|
byte[] |
getEncoded() |
byte[] |
getEncoded(boolean forTransfer)
Return an encoding of the key ring, with trust packets stripped out if forTransfer is true.
|
java.util.Iterator<PGPPublicKey> |
getKeysWithSignaturesBy(long keyID)
Return any keys carrying a signature issued by the key represented by keyID.
|
PGPPublicKey |
getPublicKey()
Return the first public key in the ring.
|
PGPPublicKey |
getPublicKey(byte[] fingerprint)
Return the public key with the passed in fingerprint if it
is present.
|
PGPPublicKey |
getPublicKey(long keyID)
Return the public key referred to by the passed in keyID if it
is present.
|
java.util.Iterator<PGPPublicKey> |
getPublicKeys()
Return an iterator containing all the public keys.
|
static PGPPublicKeyRing |
insertPublicKey(PGPPublicKeyRing pubRing,
PGPPublicKey pubKey)
Returns a new key ring with the public key passed in
either added or replacing an existing one.
|
java.util.Iterator<PGPPublicKey> |
iterator()
Support method for Iterable where available.
|
static PGPPublicKeyRing |
join(PGPPublicKeyRing first,
PGPPublicKeyRing second)
Join two copies of the same certificate.
|
static PGPPublicKeyRing |
join(PGPPublicKeyRing first,
PGPPublicKeyRing second,
boolean joinTrustPackets,
boolean allowSubkeySigsOnNonSubkey)
Join two copies of the same certificate.
|
static PGPPublicKeyRing |
removePublicKey(PGPPublicKeyRing pubRing,
PGPPublicKey pubKey)
Returns a new key ring with the public key passed in
removed from the key ring.
|
int |
size()
Return the number of keys in the key ring.
|
public PGPPublicKeyRing(byte[] encoding, KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException
java.io.IOException
public PGPPublicKeyRing(java.util.List<PGPPublicKey> pubKeys)
pubKeys
- the list of keys making up the ring.public PGPPublicKeyRing(java.io.InputStream in, KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException
java.io.IOException
public PGPPublicKey getPublicKey()
getPublicKey
in class PGPKeyRing
public PGPPublicKey getPublicKey(long keyID)
getPublicKey
in class PGPKeyRing
keyID
- the full keyID of the key of interest.public PGPPublicKey getPublicKey(byte[] fingerprint)
getPublicKey
in class PGPKeyRing
fingerprint
- the full fingerprint of the key of interest.public java.util.Iterator<PGPPublicKey> getKeysWithSignaturesBy(long keyID)
getKeysWithSignaturesBy
in class PGPKeyRing
keyID
- the key id to be matched against.public java.util.Iterator<PGPPublicKey> getPublicKeys()
getPublicKeys
in class PGPKeyRing
public java.util.Iterator<PGPPublicKey> iterator()
iterator
in interface java.lang.Iterable<PGPPublicKey>
public byte[] getEncoded() throws java.io.IOException
getEncoded
in class PGPKeyRing
java.io.IOException
public byte[] getEncoded(boolean forTransfer) throws java.io.IOException
forTransfer
- if the purpose of encoding is to send key to other users.java.io.IOException
- in case of encoding error.public int size()
size
in class PGPKeyRing
public void encode(java.io.OutputStream outStream) throws java.io.IOException
encode
in class PGPKeyRing
java.io.IOException
public void encode(java.io.OutputStream outStream, boolean forTransfer) throws java.io.IOException
outStream
- stream to write the key encoding to.forTransfer
- if the purpose of encoding is to send key to other users.java.io.IOException
- in case of encoding error.public static PGPPublicKeyRing insertPublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)
pubRing
- the public key ring to be modifiedpubKey
- the public key to be inserted.public static PGPPublicKeyRing removePublicKey(PGPPublicKeyRing pubRing, PGPPublicKey pubKey)
pubRing
- the public key ring to be modifiedpubKey
- the public key to be removed.public static PGPPublicKeyRing join(PGPPublicKeyRing first, PGPPublicKeyRing second) throws PGPException
This method will ignore trust packets on the second copy of the certificate and instead copy the local certificate's trust packets to the joined certificate.
first
- local copy of the certificatesecond
- remote copy of the certificate (e.g. from a key server)PGPException
public static PGPPublicKeyRing join(PGPPublicKeyRing first, PGPPublicKeyRing second, boolean joinTrustPackets, boolean allowSubkeySigsOnNonSubkey) throws PGPException
For each subkey holds: If joinTrustPackets is set to true and the second key is carrying a trust packet, the trust packet will be copied to the joined key. Otherwise, the joined key will carry the trust packet of the local copy.
first
- local copy of the certificatesecond
- remote copy of the certificate (e.g. from a key server)joinTrustPackets
- if true, trust packets from the second certificate copy will be carried over into the joined certificateallowSubkeySigsOnNonSubkey
- if true, the resulting joined certificate may carry subkey signatures on its primary keyPGPException