mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 14:22:05 +01:00
Add support for deleting subKeys (untested)
This commit is contained in:
parent
2d899e0a3b
commit
92e2828885
1 changed files with 13 additions and 2 deletions
|
@ -157,12 +157,23 @@ public class KeyRingEditor implements KeyRingEditorInterface {
|
|||
|
||||
@Override
|
||||
public KeyRingEditorInterface deleteSubKey(OpenPgpV4Fingerprint fingerprint, SecretKeyRingProtector protector) {
|
||||
throw new NotYetImplementedException();
|
||||
return deleteSubKey(fingerprint.getKeyId(), protector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyRingEditorInterface deleteSubKey(long subKeyId, SecretKeyRingProtector protector) {
|
||||
throw new NotYetImplementedException();
|
||||
if (secretKeyRing.getSecretKey().getKeyID() == subKeyId) {
|
||||
throw new IllegalArgumentException("You cannot delete the primary key of this key ring.");
|
||||
}
|
||||
|
||||
PGPSecretKey deleteMe = secretKeyRing.getSecretKey(subKeyId);
|
||||
if (deleteMe == null) {
|
||||
throw new NoSuchElementException("KeyRing does not contain such a key.");
|
||||
}
|
||||
|
||||
PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.removeSecretKey(secretKeyRing, deleteMe);
|
||||
secretKeyRing = newKeyRing;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue