Class SecretKeyRingEditor
- java.lang.Object
-
- org.pgpainless.key.modification.secretkeyring.SecretKeyRingEditor
-
- All Implemented Interfaces:
SecretKeyRingEditorInterface
public class SecretKeyRingEditor extends java.lang.Object implements SecretKeyRingEditorInterface
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.pgpainless.key.modification.secretkeyring.SecretKeyRingEditorInterface
SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings, SecretKeyRingEditorInterface.WithPassphrase
-
-
Constructor Summary
Constructors Constructor Description SecretKeyRingEditor(org.bouncycastle.openpgp.PGPSecretKeyRing secretKeyRing)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecretKeyRingEditorInterfaceaddSubKey(org.bouncycastle.openpgp.PGPSecretKey secretSubKey, SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector)SecretKeyRingEditorInterfaceaddSubKey(KeySpec keySpec, Passphrase subKeyPassphrase, SecretKeyRingProtector secretKeyRingProtector)Add a subkey to the key ring.SecretKeyRingEditorInterfaceaddUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)SecretKeyRingEditorInterfaceaddUserId(java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)Add a user-id to the primary key of the key ring.SecretKeyRingEditorInterface.WithKeyRingEncryptionSettingschangePassphraseFromOldPassphrase(Passphrase oldPassphrase, KeyRingProtectionSettings oldProtectionSettings)Change the passphrase of the whole key ring.SecretKeyRingEditorInterface.WithKeyRingEncryptionSettingschangeSubKeyPassphraseFromOldPassphrase(java.lang.Long keyId, Passphrase oldPassphrase, KeyRingProtectionSettings oldProtectionSettings)org.bouncycastle.openpgp.PGPSignaturecreateRevocationCertificate(long subKeyId, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)Create a detached revocation certificate, which can be used to revoke the specified key.org.bouncycastle.openpgp.PGPSignaturecreateRevocationCertificate(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)Create a detached revocation certificate, which can be used to revoke the specified key.SecretKeyRingEditorInterfacedeleteSubKey(long subKeyId, SecretKeyRingProtector protector)Delete a subkey from the key ring.SecretKeyRingEditorInterfacedeleteSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector)Delete a subkey from the key ring.SecretKeyRingEditorInterfacedeleteUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)SecretKeyRingEditorInterfacedeleteUserId(java.lang.String userId, SecretKeyRingProtector protector)Remove a user-id from the primary key of the key ring.org.bouncycastle.openpgp.PGPSecretKeyRingdone()Return thePGPSecretKeyRing.SecretKeyRingEditorInterfacerevoke(SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)Revoke the key ring.SecretKeyRingEditorInterfacerevokeSubKey(long subKeyId, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes)Revoke the subkey binding signature of a subkey.SecretKeyRingEditorInterfacerevokeSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes)Revoke the subkey binding signature of a subkey.SecretKeyRingEditorInterfacesetExpirationDate(OpenPgpV4Fingerprint fingerprint, java.util.Date expiration, SecretKeyRingProtector secretKeyRingProtector)Set key expiration time.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pgpainless.key.modification.secretkeyring.SecretKeyRingEditorInterface
addUserId, addUserId, addUserId, addUserId, changePassphraseFromOldPassphrase, changeSubKeyPassphraseFromOldPassphrase, deleteUserId, revoke, revokeSubKey, revokeSubKey
-
-
-
-
Method Detail
-
addUserId
public SecretKeyRingEditorInterface addUserId(java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceAdd a user-id to the primary key of the key ring.- Specified by:
addUserIdin interfaceSecretKeyRingEditorInterface- Parameters:
userId- user-idsecretKeyRingProtector- protector to unlock the secret key- Returns:
- the builder
- Throws:
org.bouncycastle.openpgp.PGPException
-
addUserId
public SecretKeyRingEditorInterface addUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector) throws org.bouncycastle.openpgp.PGPException
- Specified by:
addUserIdin interfaceSecretKeyRingEditorInterface- Throws:
org.bouncycastle.openpgp.PGPException
-
deleteUserId
public SecretKeyRingEditorInterface deleteUserId(java.lang.String userId, SecretKeyRingProtector protector)
Description copied from interface:SecretKeyRingEditorInterfaceRemove a user-id from the primary key of the key ring.- Specified by:
deleteUserIdin interfaceSecretKeyRingEditorInterface- Parameters:
userId- exact user-id to be removedprotector- protector to unlock the secret key- Returns:
- the builder
-
deleteUserId
public SecretKeyRingEditorInterface deleteUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)
- Specified by:
deleteUserIdin interfaceSecretKeyRingEditorInterface
-
addSubKey
public SecretKeyRingEditorInterface addSubKey(@Nonnull KeySpec keySpec, @Nonnull Passphrase subKeyPassphrase, SecretKeyRingProtector secretKeyRingProtector) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceAdd a subkey to the key ring. The subkey will be generated from the providedKeySpec.- Specified by:
addSubKeyin interfaceSecretKeyRingEditorInterface- Parameters:
keySpec- key specificationsubKeyPassphrase- passphrase to encrypt the sub keysecretKeyRingProtector- protector to unlock the secret key of the key ring- Returns:
- the builder
- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
addSubKey
public SecretKeyRingEditorInterface addSubKey(org.bouncycastle.openpgp.PGPSecretKey secretSubKey, SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector) throws org.bouncycastle.openpgp.PGPException
- Specified by:
addSubKeyin interfaceSecretKeyRingEditorInterface- Throws:
org.bouncycastle.openpgp.PGPException
-
deleteSubKey
public SecretKeyRingEditorInterface deleteSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector)
Description copied from interface:SecretKeyRingEditorInterfaceDelete a subkey from the key ring. The subkey with the provided fingerprint will be remove from the key ring. If no suitable subkey is found, aNoSuchElementExceptionwill be thrown.- Specified by:
deleteSubKeyin interfaceSecretKeyRingEditorInterface- Parameters:
fingerprint- fingerprint of the subkey to be removedprotector- protector to unlock the secret key ring- Returns:
- the builder
-
deleteSubKey
public SecretKeyRingEditorInterface deleteSubKey(long subKeyId, SecretKeyRingProtector protector)
Description copied from interface:SecretKeyRingEditorInterfaceDelete a subkey from the key ring. The subkey with the provided key-id will be removed from the key ring. If no suitable subkey is found, aNoSuchElementExceptionwill be thrown.- Specified by:
deleteSubKeyin interfaceSecretKeyRingEditorInterface- Parameters:
subKeyId- id of the subkeyprotector- protector to unlock the secret key ring- Returns:
- the builder
-
revoke
public SecretKeyRingEditorInterface revoke(SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceRevoke the key ring.- Specified by:
revokein interfaceSecretKeyRingEditorInterface- Parameters:
secretKeyRingProtector- protector of the primary keyrevocationAttributes- reason for the revocation- Returns:
- the builder
- Throws:
org.bouncycastle.openpgp.PGPException
-
revokeSubKey
public SecretKeyRingEditorInterface revokeSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceRevoke the subkey binding signature of a subkey. The subkey with the provided fingerprint will be revoked. If no suitable subkey is found, aNoSuchElementExceptionwill be thrown.- Specified by:
revokeSubKeyin interfaceSecretKeyRingEditorInterface- Parameters:
fingerprint- fingerprint of the subkey to be revokedprotector- protector to unlock the primary keyrevocationAttributes- reason for the revocation- Returns:
- the builder
- Throws:
org.bouncycastle.openpgp.PGPException
-
revokeSubKey
public SecretKeyRingEditorInterface revokeSubKey(long subKeyId, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceRevoke the subkey binding signature of a subkey. The subkey with the provided key-id will be revoked. If no suitable subkey is found, qNoSuchElementExceptionwill be thrown.- Specified by:
revokeSubKeyin interfaceSecretKeyRingEditorInterface- Parameters:
subKeyId- id of the subkeyprotector- protector to unlock the primary keyrevocationAttributes- reason for the revocation- Returns:
- the builder
- Throws:
org.bouncycastle.openpgp.PGPException
-
setExpirationDate
public SecretKeyRingEditorInterface setExpirationDate(OpenPgpV4Fingerprint fingerprint, java.util.Date expiration, SecretKeyRingProtector secretKeyRingProtector) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceSet key expiration time.- Specified by:
setExpirationDatein interfaceSecretKeyRingEditorInterface- Parameters:
fingerprint- key that will have its expiration date adjustedexpiration- target expiration time or @{code null} for no expirationsecretKeyRingProtector- protector to unlock the priary key- Returns:
- the builder
- Throws:
org.bouncycastle.openpgp.PGPException
-
createRevocationCertificate
public org.bouncycastle.openpgp.PGPSignature createRevocationCertificate(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes) throws org.bouncycastle.openpgp.PGPException
Description copied from interface:SecretKeyRingEditorInterfaceCreate a detached revocation certificate, which can be used to revoke the specified key.- Specified by:
createRevocationCertificatein interfaceSecretKeyRingEditorInterface- Parameters:
fingerprint- fingerprint of the key to be revoked. Can be primary or sub key.secretKeyRingProtector- protector to unlock the primary key.revocationAttributes- reason for the revocation- Returns:
- revocation certificate
- Throws:
org.bouncycastle.openpgp.PGPException
-
createRevocationCertificate
public org.bouncycastle.openpgp.PGPSignature createRevocationCertificate(long subKeyId, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes) throws org.bouncycastle.openpgp.PGPExceptionDescription copied from interface:SecretKeyRingEditorInterfaceCreate a detached revocation certificate, which can be used to revoke the specified key.- Specified by:
createRevocationCertificatein interfaceSecretKeyRingEditorInterface- Parameters:
subKeyId- id of the key to be revoked. Can be primary or sub key.secretKeyRingProtector- protector to unlock the primary key.revocationAttributes- reason for the revocation- Returns:
- revocation certificate
- Throws:
org.bouncycastle.openpgp.PGPException
-
changePassphraseFromOldPassphrase
public SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings changePassphraseFromOldPassphrase(@Nullable Passphrase oldPassphrase, @Nonnull KeyRingProtectionSettings oldProtectionSettings)
Description copied from interface:SecretKeyRingEditorInterfaceChange the passphrase of the whole key ring.- Specified by:
changePassphraseFromOldPassphrasein interfaceSecretKeyRingEditorInterface- Parameters:
oldPassphrase- old passphrase or null, if the key was unprotectedoldProtectionSettings- custom settings for the old passphrase- Returns:
- next builder step
-
changeSubKeyPassphraseFromOldPassphrase
public SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings changeSubKeyPassphraseFromOldPassphrase(@Nonnull java.lang.Long keyId, @Nullable Passphrase oldPassphrase, @Nonnull KeyRingProtectionSettings oldProtectionSettings)
- Specified by:
changeSubKeyPassphraseFromOldPassphrasein interfaceSecretKeyRingEditorInterface
-
done
public org.bouncycastle.openpgp.PGPSecretKeyRing done()
Description copied from interface:SecretKeyRingEditorInterfaceReturn thePGPSecretKeyRing.- Specified by:
donein interfaceSecretKeyRingEditorInterface- Returns:
- the key
-
-