mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-01-08 19:27:57 +01:00
SecretKeyRingEditor: Add revoke() shortcut method
This commit is contained in:
parent
d7aea4b0f7
commit
93abfd5517
3 changed files with 30 additions and 1 deletions
|
@ -257,6 +257,13 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecretKeyRingEditorInterface revoke(SecretKeyRingProtector secretKeyRingProtector,
|
||||
RevocationAttributes revocationAttributes)
|
||||
throws PGPException {
|
||||
return revokeSubKey(secretKeyRing.getSecretKey().getKeyID(), secretKeyRingProtector, revocationAttributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecretKeyRingEditorInterface revokeSubKey(OpenPgpV4Fingerprint fingerprint,
|
||||
SecretKeyRingProtector protector,
|
||||
|
|
|
@ -109,6 +109,28 @@ public interface SecretKeyRingEditorInterface {
|
|||
*/
|
||||
SecretKeyRingEditorInterface deleteSubKey(long subKeyId, SecretKeyRingProtector secretKeyRingProtector);
|
||||
|
||||
/**
|
||||
* Revoke the key ring.
|
||||
*
|
||||
* @param secretKeyRingProtector protector of the primary key
|
||||
* @return the builder
|
||||
*/
|
||||
default SecretKeyRingEditorInterface revoke(SecretKeyRingProtector secretKeyRingProtector)
|
||||
throws PGPException {
|
||||
return revoke(secretKeyRingProtector, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke the key ring.
|
||||
*
|
||||
* @param secretKeyRingProtector protector of the primary key
|
||||
* @param revocationAttributes reason for the revocation
|
||||
* @return the builder
|
||||
*/
|
||||
SecretKeyRingEditorInterface revoke(SecretKeyRingProtector secretKeyRingProtector,
|
||||
RevocationAttributes revocationAttributes)
|
||||
throws PGPException;
|
||||
|
||||
/**
|
||||
* Revoke the subkey binding signature of a subkey.
|
||||
* The subkey with the provided fingerprint will be revoked.
|
||||
|
|
|
@ -73,7 +73,7 @@ public class KeyRingInfoTest {
|
|||
assertNull(sInfo.getRevocationDate());
|
||||
assertNull(pInfo.getRevocationDate());
|
||||
Date revocationDate = new Date();
|
||||
PGPSecretKeyRing revoked = PGPainless.modifyKeyRing(secretKeys).revokeSubKey(sInfo.getKeyId(), new UnprotectedKeysProtector()).done();
|
||||
PGPSecretKeyRing revoked = PGPainless.modifyKeyRing(secretKeys).revoke(new UnprotectedKeysProtector()).done();
|
||||
KeyRingInfo rInfo = PGPainless.inspectKeyRing(revoked);
|
||||
assertNotNull(rInfo.getRevocationDate());
|
||||
assertEquals(revocationDate.getTime(), rInfo.getRevocationDate().getTime(), 1000);
|
||||
|
|
Loading…
Reference in a new issue