1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-06-14 15:44:51 +02:00

SecretKeyRingEditor: Add revoke() shortcut method

This commit is contained in:
Paul Schaub 2020-11-22 21:25:52 +01:00
parent d7aea4b0f7
commit 93abfd5517
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 30 additions and 1 deletions

View file

@ -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,

View file

@ -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.

View file

@ -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);