mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-11 06:41:09 +01:00
SOP: Allow generation of keys without user-ids
This commit is contained in:
parent
66abd5f65f
commit
2d46fb18f7
3 changed files with 32 additions and 37 deletions
|
|
@ -28,7 +28,7 @@ public class GenerateKeyImpl implements GenerateKey {
|
|||
|
||||
private boolean armor = true;
|
||||
private final Set<String> userIds = new LinkedHashSet<>();
|
||||
private Passphrase passphrase;
|
||||
private Passphrase passphrase = Passphrase.emptyPassphrase();
|
||||
|
||||
@Override
|
||||
public GenerateKey noArmor() {
|
||||
|
|
@ -51,14 +51,11 @@ public class GenerateKeyImpl implements GenerateKey {
|
|||
@Override
|
||||
public Ready generate() throws SOPGPException.MissingArg, SOPGPException.UnsupportedAsymmetricAlgo {
|
||||
Iterator<String> userIdIterator = userIds.iterator();
|
||||
if (!userIdIterator.hasNext()) {
|
||||
throw new SOPGPException.MissingArg("Missing user-id.");
|
||||
}
|
||||
|
||||
PGPSecretKeyRing key;
|
||||
try {
|
||||
String primaryUserId = userIdIterator.hasNext() ? userIdIterator.next() : null;
|
||||
key = PGPainless.generateKeyRing()
|
||||
.modernKeyRing(userIdIterator.next(), passphrase);
|
||||
.modernKeyRing(primaryUserId, passphrase);
|
||||
|
||||
if (userIdIterator.hasNext()) {
|
||||
SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue