1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 18:59:39 +02:00

Remove ImplementationFactory in favor of BCs OpenPGPImplementation

This commit is contained in:
Paul Schaub 2025-03-07 14:48:03 +01:00
parent 0bc80d86d3
commit 76963ec3ec
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
48 changed files with 303 additions and 550 deletions

View file

@ -22,10 +22,10 @@ import org.bouncycastle.openpgp.PGPObjectFactory;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureList;
import org.bouncycastle.openpgp.api.OpenPGPImplementation;
import org.bouncycastle.util.io.Streams;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.implementation.ImplementationFactory;
import org.pgpainless.key.OpenPgpV4Fingerprint;
import sop.ByteArrayAndResult;
import sop.SOP;
@ -153,13 +153,13 @@ public class InlineDetachTest {
ByteArrayOutputStream literalDataAndSignatures = new ByteArrayOutputStream();
ArmoredInputStream armorIn = new ArmoredInputStream(new ByteArrayInputStream(inlineSigned));
PGPObjectFactory objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(armorIn);
PGPObjectFactory objectFactory = OpenPGPImplementation.getInstance().pgpObjectFactory(armorIn);
Object next;
while ((next = objectFactory.nextObject()) != null) {
if (next instanceof PGPCompressedData) {
PGPCompressedData compressedData = (PGPCompressedData) next;
try {
objectFactory = ImplementationFactory.getInstance().getPGPObjectFactory(compressedData.getDataStream());
objectFactory = OpenPGPImplementation.getInstance().pgpObjectFactory(compressedData.getDataStream());
} catch (PGPException e) {
throw new SOPGPException.BadData("Cannot decompress compressed data", e);
}

View file

@ -96,13 +96,13 @@ public class MatchMakingSecretKeyRingProtectorTest {
MatchMakingSecretKeyRingProtector protector = new MatchMakingSecretKeyRingProtector();
protector.addSecretKey(unprotectedKey);
assertTrue(protector.hasPassphraseFor(unprotectedKey.getPublicKey().getKeyID()));
assertNull(protector.getEncryptor(unprotectedKey.getPublicKey().getKeyID()));
assertNull(protector.getEncryptor(unprotectedKey.getPublicKey()));
assertNull(protector.getDecryptor(unprotectedKey.getPublicKey().getKeyID()));
PGPSecretKeyRing protectedKey = PGPainless.readKeyRing().secretKeyRing(PROTECTED_KEY);
protector.addSecretKey(protectedKey);
protector.addPassphrase(Passphrase.fromPassword(PASSWORD));
assertNotNull(protector.getEncryptor(protectedKey.getPublicKey().getKeyID()));
assertNotNull(protector.getEncryptor(protectedKey.getPublicKey()));
assertNotNull(protector.getDecryptor(protectedKey.getPublicKey().getKeyID()));
}
}