mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-15 05:09:38 +02:00
Wip: Allow for additional user-ids to be added
This commit is contained in:
parent
6a4fa47c12
commit
8c30db9bf1
3 changed files with 118 additions and 15 deletions
|
@ -0,0 +1,38 @@
|
|||
package org.pgpainless.key.generation;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bouncycastle.bcpg.ArmoredOutputStream;
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.junit.Test;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.collection.PGPKeyRing;
|
||||
import org.pgpainless.key.generation.type.KeyType;
|
||||
import org.pgpainless.key.generation.type.RSA_SIGN;
|
||||
import org.pgpainless.key.generation.type.length.RsaLength;
|
||||
|
||||
public class GenerateKeyWithAdditionalUserIdTest {
|
||||
|
||||
@Test
|
||||
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||
PGPKeyRing keyRing = PGPainless.generateKeyRing()
|
||||
.withMasterKey(KeySpec.getBuilder(RSA_SIGN.withLength(RsaLength._3072))
|
||||
.withDefaultKeyFlags()
|
||||
.withDefaultAlgorithms())
|
||||
.withPrimaryUserId("primary@user.id")
|
||||
.withAdditionalUserId("additional@user.id")
|
||||
.withoutPassphrase()
|
||||
.build();
|
||||
|
||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
ArmoredOutputStream armor = new ArmoredOutputStream(byteOut);
|
||||
keyRing.getSecretKeys().encode(armor);
|
||||
armor.close();
|
||||
|
||||
System.out.println(byteOut.toString("UTF-8"));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue