Package org.bouncycastle.openpgp.api
Class OpenPGPKeyEditor
java.lang.Object
org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
org.bouncycastle.openpgp.api.OpenPGPKeyEditor
-
Field Summary
Fields inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
defaultAeadAlgorithmPreferences, defaultCompressionAlgorithmPreferences, defaultFeatures, defaultHashAlgorithmPreferences, defaultSymmetricKeyPreferences, directKeySignatureSubpackets, encryptionSubkeySubpackets, signingSubkeySubpackets
-
Constructor Summary
ConstructorsConstructorDescriptionOpenPGPKeyEditor
(OpenPGPKey key, KeyPassphraseProvider passphraseProvider) OpenPGPKeyEditor
(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, OpenPGPImplementation implementation) OpenPGPKeyEditor
(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, OpenPGPImplementation implementation, OpenPGPPolicy policy) -
Method Summary
Modifier and TypeMethodDescriptionaddDirectKeySignature
(SignatureParameters.Callback signatureCallback) addEncryptionSubkey
(KeyPairGeneratorCallback keyGenCallback) addEncryptionSubkey
(KeyPairGeneratorCallback keyGenCallback, int version, Date creationTime) addEncryptionSubkey
(PGPKeyPair encryptionSubkey, SignatureParameters.Callback bindingSigCallback) addSigningSubkey
(KeyPairGeneratorCallback keyGenCallback) addSigningSubkey
(KeyPairGeneratorCallback keyGenCallback, int version, Date creationTime) addSigningSubkey
(PGPKeyPair signingSubkey, SignatureParameters.Callback bindingSigCallback, SignatureParameters.Callback backSigCallback) addSubkey
(PGPKeyPair subkey, SignatureParameters.Callback bindingSigCallback, SignatureParameters.Callback backSigCallback) Add a component key to the certificate.Add a user-id to the primary key.addUserId
(String userId, SignatureParameters.Callback signatureCallback) Add a user-id to the primary key, modifying the contents of the certification signature using the givenSignatureParameters.Callback
.changePassphrase
(KeyIdentifier componentKeyIdentifier, char[] oldPassphrase, char[] newPassphrase, boolean useAEAD) Change the passphrase of the given component key.done()
Return the modifiedOpenPGPKey
.revokeComponentKey
(OpenPGPCertificate.OpenPGPComponentKey componentKey) revokeComponentKey
(OpenPGPCertificate.OpenPGPComponentKey componentKey, SignatureParameters.Callback revocationSignatureCallback) Revoke the givenOpenPGPCertificate.OpenPGPIdentityComponent
.revokeIdentity
(OpenPGPCertificate.OpenPGPIdentityComponent identity, SignatureParameters.Callback signatureCallback) Revoke the givenOpenPGPCertificate.OpenPGPUserId
, allowing modification of the revocation signature using the givenSignatureParameters.Callback
.revokeKey
(SignatureParameters.Callback revocationSignatureCallback) Methods inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
setDefaultAeadAlgorithmPreferences, setDefaultCompressionAlgorithmPreferences, setDefaultFeatures, setDefaultHashAlgorithmPreferences, setDefaultSymmetricKeyPreferences, setDirectKeySignatureSubpackets, setEncryptionSubkeySubpackets, setSigningSubkeySubpackets
-
Constructor Details
-
OpenPGPKeyEditor
public OpenPGPKeyEditor(OpenPGPKey key, KeyPassphraseProvider passphraseProvider) throws PGPException - Throws:
PGPException
-
OpenPGPKeyEditor
public OpenPGPKeyEditor(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, OpenPGPImplementation implementation) throws PGPException - Throws:
PGPException
-
OpenPGPKeyEditor
public OpenPGPKeyEditor(OpenPGPKey key, KeyPassphraseProvider passphraseProvider, OpenPGPImplementation implementation, OpenPGPPolicy policy) throws PGPException - Throws:
PGPException
-
-
Method Details
-
addDirectKeySignature
public OpenPGPKeyEditor addDirectKeySignature(SignatureParameters.Callback signatureCallback) throws PGPException - Throws:
PGPException
-
addUserId
Add a user-id to the primary key. If the key already contains the given user-id, a new certification signature will be added to the user-id.- Parameters:
userId
- user-id- Returns:
- this
- Throws:
PGPException
- if the key cannot be modified
-
addUserId
public OpenPGPKeyEditor addUserId(String userId, SignatureParameters.Callback signatureCallback) throws PGPException Add a user-id to the primary key, modifying the contents of the certification signature using the givenSignatureParameters.Callback
. If the key already contains the given user-id, a new certification signature will be added to the user-id.- Parameters:
userId
- user-idsignatureCallback
- callback to modify the certification signature contents- Returns:
- this
- Throws:
PGPException
- if the key cannot be modified
-
revokeIdentity
public OpenPGPKeyEditor revokeIdentity(OpenPGPCertificate.OpenPGPIdentityComponent identity) throws PGPException Revoke the givenOpenPGPCertificate.OpenPGPIdentityComponent
.- Parameters:
identity
- user-id to be revoked- Returns:
- this
- Throws:
PGPException
- if the key cannot be modified
-
revokeIdentity
public OpenPGPKeyEditor revokeIdentity(OpenPGPCertificate.OpenPGPIdentityComponent identity, SignatureParameters.Callback signatureCallback) throws PGPException Revoke the givenOpenPGPCertificate.OpenPGPUserId
, allowing modification of the revocation signature using the givenSignatureParameters.Callback
.- Parameters:
identity
- user-id to revokesignatureCallback
- callback to modify the revocation signature contents- Returns:
- this
- Throws:
PGPException
- if the key cannot be modified
-
addEncryptionSubkey
- Throws:
PGPException
-
addEncryptionSubkey
public OpenPGPKeyEditor addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback) throws PGPException - Throws:
PGPException
-
addEncryptionSubkey
public OpenPGPKeyEditor addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, int version, Date creationTime) throws PGPException - Throws:
PGPException
-
addEncryptionSubkey
public OpenPGPKeyEditor addEncryptionSubkey(PGPKeyPair encryptionSubkey, SignatureParameters.Callback bindingSigCallback) throws PGPException - Throws:
PGPException
-
addSigningSubkey
- Throws:
PGPException
-
addSigningSubkey
public OpenPGPKeyEditor addSigningSubkey(KeyPairGeneratorCallback keyGenCallback) throws PGPException - Throws:
PGPException
-
addSigningSubkey
public OpenPGPKeyEditor addSigningSubkey(KeyPairGeneratorCallback keyGenCallback, int version, Date creationTime) throws PGPException - Throws:
PGPException
-
addSigningSubkey
public OpenPGPKeyEditor addSigningSubkey(PGPKeyPair signingSubkey, SignatureParameters.Callback bindingSigCallback, SignatureParameters.Callback backSigCallback) throws PGPException - Throws:
PGPException
-
addSubkey
public OpenPGPKeyEditor addSubkey(PGPKeyPair subkey, SignatureParameters.Callback bindingSigCallback, SignatureParameters.Callback backSigCallback) throws PGPException Add a component key to the certificate. The bindingSigCallback can be used to modify the subkey binding signature. If it is null, no subkey binding signature will be generated. The backSigCallback can be used to modify the embedded primary key binding signature. If it is null, no primary key binding signature will be generated. You MUST only pass a non-null value here, if the subkey is capable of creating signatures.- Parameters:
subkey
- component keybindingSigCallback
- callback to modify the subkey binding signaturebackSigCallback
- callback to modify the embedded primary key binding signature- Returns:
- this
- Throws:
PGPException
-
revokeComponentKey
public OpenPGPKeyEditor revokeComponentKey(OpenPGPCertificate.OpenPGPComponentKey componentKey) throws PGPException - Throws:
PGPException
-
revokeComponentKey
public OpenPGPKeyEditor revokeComponentKey(OpenPGPCertificate.OpenPGPComponentKey componentKey, SignatureParameters.Callback revocationSignatureCallback) throws PGPException - Throws:
PGPException
-
revokeKey
- Throws:
PGPException
-
revokeKey
public OpenPGPKeyEditor revokeKey(SignatureParameters.Callback revocationSignatureCallback) throws PGPException - Throws:
PGPException
-
changePassphrase
public OpenPGPKeyEditor changePassphrase(KeyIdentifier componentKeyIdentifier, char[] oldPassphrase, char[] newPassphrase, boolean useAEAD) throws OpenPGPKeyException, PGPException Change the passphrase of the given component key.- Parameters:
componentKeyIdentifier
- identifier of the component key, whose passphrase shall be changedoldPassphrase
- old passphrase (or null)newPassphrase
- new passphrase (or null)useAEAD
- whether to use AEAD- Returns:
- this
- Throws:
OpenPGPKeyException
- if the secret component of the component key is missingPGPException
- if the key passphrase cannot be changed
-
done
Return the modifiedOpenPGPKey
.- Returns:
- modified key
-