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 SecretKeyRingEditorInterface
addSubKey(org.bouncycastle.openpgp.PGPSecretKey secretSubKey, SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector)
SecretKeyRingEditorInterface
addSubKey(KeySpec keySpec, Passphrase subKeyPassphrase, SecretKeyRingProtector secretKeyRingProtector)
Add a subkey to the key ring.SecretKeyRingEditorInterface
addUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)
SecretKeyRingEditorInterface
addUserId(java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)
Add a user-id to the primary key of the key ring.SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings
changePassphraseFromOldPassphrase(Passphrase oldPassphrase, KeyRingProtectionSettings oldProtectionSettings)
Change the passphrase of the whole key ring.SecretKeyRingEditorInterface.WithKeyRingEncryptionSettings
changeSubKeyPassphraseFromOldPassphrase(java.lang.Long keyId, Passphrase oldPassphrase, KeyRingProtectionSettings oldProtectionSettings)
org.bouncycastle.openpgp.PGPSignature
createRevocationCertificate(long subKeyId, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)
Create a detached revocation certificate, which can be used to revoke the specified key.org.bouncycastle.openpgp.PGPSignature
createRevocationCertificate(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)
Create a detached revocation certificate, which can be used to revoke the specified key.SecretKeyRingEditorInterface
deleteSubKey(long subKeyId, SecretKeyRingProtector protector)
Delete a subkey from the key ring.SecretKeyRingEditorInterface
deleteSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector)
Delete a subkey from the key ring.SecretKeyRingEditorInterface
deleteUserId(long keyId, java.lang.String userId, SecretKeyRingProtector secretKeyRingProtector)
SecretKeyRingEditorInterface
deleteUserId(java.lang.String userId, SecretKeyRingProtector protector)
Remove a user-id from the primary key of the key ring.org.bouncycastle.openpgp.PGPSecretKeyRing
done()
Return thePGPSecretKeyRing
.SecretKeyRingEditorInterface
revoke(SecretKeyRingProtector secretKeyRingProtector, RevocationAttributes revocationAttributes)
Revoke the key ring.SecretKeyRingEditorInterface
revokeSubKey(long subKeyId, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes)
Revoke the subkey binding signature of a subkey.SecretKeyRingEditorInterface
revokeSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector, RevocationAttributes revocationAttributes)
Revoke the subkey binding signature of a subkey.SecretKeyRingEditorInterface
setExpirationDate(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:SecretKeyRingEditorInterface
Add a user-id to the primary key of the key ring.- Specified by:
addUserId
in 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:
addUserId
in interfaceSecretKeyRingEditorInterface
- Throws:
org.bouncycastle.openpgp.PGPException
-
deleteUserId
public SecretKeyRingEditorInterface deleteUserId(java.lang.String userId, SecretKeyRingProtector protector)
Description copied from interface:SecretKeyRingEditorInterface
Remove a user-id from the primary key of the key ring.- Specified by:
deleteUserId
in 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:
deleteUserId
in 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:SecretKeyRingEditorInterface
Add a subkey to the key ring. The subkey will be generated from the providedKeySpec
.- Specified by:
addSubKey
in 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.InvalidAlgorithmParameterException
java.security.NoSuchAlgorithmException
org.bouncycastle.openpgp.PGPException
-
addSubKey
public SecretKeyRingEditorInterface addSubKey(org.bouncycastle.openpgp.PGPSecretKey secretSubKey, SecretKeyRingProtector subKeyProtector, SecretKeyRingProtector keyRingProtector) throws org.bouncycastle.openpgp.PGPException
- Specified by:
addSubKey
in interfaceSecretKeyRingEditorInterface
- Throws:
org.bouncycastle.openpgp.PGPException
-
deleteSubKey
public SecretKeyRingEditorInterface deleteSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector)
Description copied from interface:SecretKeyRingEditorInterface
Delete 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, aNoSuchElementException
will be thrown.- Specified by:
deleteSubKey
in 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:SecretKeyRingEditorInterface
Delete 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, aNoSuchElementException
will be thrown.- Specified by:
deleteSubKey
in 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:SecretKeyRingEditorInterface
Revoke the key ring.- Specified by:
revoke
in 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:SecretKeyRingEditorInterface
Revoke the subkey binding signature of a subkey. The subkey with the provided fingerprint will be revoked. If no suitable subkey is found, aNoSuchElementException
will be thrown.- Specified by:
revokeSubKey
in 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:SecretKeyRingEditorInterface
Revoke the subkey binding signature of a subkey. The subkey with the provided key-id will be revoked. If no suitable subkey is found, qNoSuchElementException
will be thrown.- Specified by:
revokeSubKey
in 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:SecretKeyRingEditorInterface
Set key expiration time.- Specified by:
setExpirationDate
in 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:SecretKeyRingEditorInterface
Create a detached revocation certificate, which can be used to revoke the specified key.- Specified by:
createRevocationCertificate
in 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.PGPException
Description copied from interface:SecretKeyRingEditorInterface
Create a detached revocation certificate, which can be used to revoke the specified key.- Specified by:
createRevocationCertificate
in 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:SecretKeyRingEditorInterface
Change the passphrase of the whole key ring.- Specified by:
changePassphraseFromOldPassphrase
in 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:
changeSubKeyPassphraseFromOldPassphrase
in interfaceSecretKeyRingEditorInterface
-
done
public org.bouncycastle.openpgp.PGPSecretKeyRing done()
Description copied from interface:SecretKeyRingEditorInterface
Return thePGPSecretKeyRing
.- Specified by:
done
in interfaceSecretKeyRingEditorInterface
- Returns:
- the key
-
-