mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-10 14:21:09 +01:00
Add tests for KeyRingUtils.injectCertification and render keysPlusPublicKey unusable
This commit is contained in:
parent
03912f9dc1
commit
635de19fb8
2 changed files with 53 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
|||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVector;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.exception.NotYetImplementedException;
|
||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||
import org.pgpainless.key.protection.UnlockSecretKey;
|
||||
|
||||
|
|
@ -299,6 +300,10 @@ public final class KeyRingUtils {
|
|||
}
|
||||
|
||||
public static <T extends PGPKeyRing> T keysPlusPublicKey(T keyRing, PGPPublicKey publicKey) {
|
||||
if (true)
|
||||
// Is currently broken beyond repair
|
||||
throw new NotYetImplementedException();
|
||||
|
||||
PGPSecretKeyRing secretKeys = null;
|
||||
PGPPublicKeyRing publicKeys;
|
||||
if (keyRing instanceof PGPSecretKeyRing) {
|
||||
|
|
@ -312,6 +317,9 @@ public final class KeyRingUtils {
|
|||
if (secretKeys == null) {
|
||||
return (T) publicKeys;
|
||||
} else {
|
||||
// TODO: Replace with PGPSecretKeyRing.insertOrReplacePublicKey() once available
|
||||
// Right now replacePublicKeys looses extra public keys.
|
||||
// See https://github.com/bcgit/bc-java/pull/1068 for a possible fix
|
||||
secretKeys = PGPSecretKeyRing.replacePublicKeys(secretKeys, publicKeys);
|
||||
return (T) secretKeys;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue