public class PGPSecretKeyRing extends PGPKeyRing implements org.bouncycastle.util.Iterable<PGPSecretKey>
Often PGP keyring files consist of multiple master keys, if you are trying to process
or construct one of these you should use the PGPSecretKeyRingCollection
class.
Constructor and Description |
---|
PGPSecretKeyRing(byte[] encoding,
KeyFingerPrintCalculator fingerPrintCalculator) |
PGPSecretKeyRing(java.io.InputStream in,
KeyFingerPrintCalculator fingerPrintCalculator) |
PGPSecretKeyRing(java.util.List<PGPSecretKey> secKeys)
Base constructor from a list of keys representing a secret key ring (a master key and its
associated sub-keys).
|
Modifier and Type | Method and Description |
---|---|
static PGPSecretKeyRing |
copyWithNewPassword(PGPSecretKeyRing ring,
PBESecretKeyDecryptor oldKeyDecryptor,
PBESecretKeyEncryptor newKeyEncryptor)
Return a copy of the passed in secret key ring, with the private keys (where present) associated with the master key and sub keys
are encrypted using a new password and the passed in algorithm.
|
void |
encode(java.io.OutputStream outStream) |
byte[] |
getEncoded() |
java.util.Iterator<PGPPublicKey> |
getExtraPublicKeys()
Return an iterator of the public keys in the secret key ring that
have no matching private key.
|
java.util.Iterator<PGPPublicKey> |
getKeysWithSignaturesBy(long keyID)
Return any keys carrying a signature issued by the key represented by keyID.
|
PGPPublicKey |
getPublicKey()
Return the public key for the master key.
|
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.
|
PGPSecretKey |
getSecretKey()
Return the master private key.
|
PGPSecretKey |
getSecretKey(byte[] fingerprint)
Return the secret key associated with the passed in fingerprint if it
is present.
|
PGPSecretKey |
getSecretKey(long keyID)
Return the secret key referred to by the passed in keyID if it
is present.
|
java.util.Iterator<PGPSecretKey> |
getSecretKeys()
Return an iterator containing all the secret keys.
|
static PGPSecretKeyRing |
insertOrReplacePublicKey(PGPSecretKeyRing secretRing,
PGPPublicKey publicKey)
Either replace the public key on the corresponding secret key in the key ring if present,
or insert the public key as an extra public key in case that the secret ring does not
contain the corresponding secret key.
|
static PGPSecretKeyRing |
insertSecretKey(PGPSecretKeyRing secRing,
PGPSecretKey secKey)
Returns a new key ring with the secret key passed in either added or
replacing an existing one with the same key ID.
|
java.util.Iterator<PGPSecretKey> |
iterator()
Support method for Iterable where available.
|
static PGPSecretKeyRing |
removeSecretKey(PGPSecretKeyRing secRing,
PGPSecretKey secKey)
Returns a new key ring with the secret key passed in removed from the
key ring.
|
static PGPSecretKeyRing |
replacePublicKeys(PGPSecretKeyRing secretRing,
PGPPublicKeyRing publicRing)
Replace the public key set on the secret ring with the corresponding key off the public ring.
|
public PGPSecretKeyRing(java.util.List<PGPSecretKey> secKeys)
secKeys
- the list of keys making up the ring.public PGPSecretKeyRing(byte[] encoding, KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException, PGPException
java.io.IOException
PGPException
public PGPSecretKeyRing(java.io.InputStream in, KeyFingerPrintCalculator fingerPrintCalculator) throws java.io.IOException, PGPException
java.io.IOException
PGPException
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 PGPSecretKey getSecretKey()
public java.util.Iterator<PGPSecretKey> getSecretKeys()
public PGPSecretKey getSecretKey(long keyID)
keyID
- the full keyID of the key of interest.public PGPSecretKey getSecretKey(byte[] fingerprint)
fingerprint
- the full fingerprint of the key of interest.public java.util.Iterator<PGPPublicKey> getExtraPublicKeys()
public byte[] getEncoded() throws java.io.IOException
getEncoded
in class PGPKeyRing
java.io.IOException
public void encode(java.io.OutputStream outStream) throws java.io.IOException
encode
in class PGPKeyRing
java.io.IOException
public java.util.Iterator<PGPSecretKey> iterator()
iterator
in interface java.lang.Iterable<PGPSecretKey>
public static PGPSecretKeyRing replacePublicKeys(PGPSecretKeyRing secretRing, PGPPublicKeyRing publicRing)
secretRing
- secret ring to be changed.publicRing
- public ring containing the new public key set.public static PGPSecretKeyRing insertOrReplacePublicKey(PGPSecretKeyRing secretRing, PGPPublicKey publicKey)
secretRing
- secret key ringpublicKey
- public key to insert or replacepublic static PGPSecretKeyRing copyWithNewPassword(PGPSecretKeyRing ring, PBESecretKeyDecryptor oldKeyDecryptor, PBESecretKeyEncryptor newKeyEncryptor) throws PGPException
ring
- the PGPSecretKeyRing to be copied.oldKeyDecryptor
- the current decryptor based on the current password for key.newKeyEncryptor
- a new encryptor based on a new password for encrypting the secret key material.PGPException
public static PGPSecretKeyRing insertSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)
secRing
- the secret key ring to be modified.secKey
- the secret key to be added.public static PGPSecretKeyRing removeSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)
secRing
- the secret key ring to be modified.secKey
- the secret key to be removed.