1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-30 08:12:06 +01:00

Implement merging of certificates

Fixes #211
This commit is contained in:
Paul Schaub 2022-04-07 19:51:42 +02:00
parent 864bfad80c
commit 73fa46895e
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -8,6 +8,7 @@ import java.io.IOException;
import java.util.Date; import java.util.Date;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyRing; import org.bouncycastle.openpgp.PGPKeyRing;
import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing;
@ -66,6 +67,21 @@ public final class PGPainless {
return KeyRingUtils.publicKeyRingFrom(secretKey); return KeyRingUtils.publicKeyRingFrom(secretKey);
} }
/**
* Merge two copies of the same certificate (e.g. an old copy, and one retrieved from a key server) together.
*
* @param originalCopy local, older copy of the cert
* @param updatedCopy updated, newer copy of the cert
* @return merged certificate
* @throws PGPException in case of an error
*/
public static PGPPublicKeyRing mergeCertificate(
@Nonnull PGPPublicKeyRing originalCopy,
@Nonnull PGPPublicKeyRing updatedCopy)
throws PGPException {
return PGPPublicKeyRing.join(originalCopy, updatedCopy);
}
/** /**
* Wrap a key or certificate in ASCII armor. * Wrap a key or certificate in ASCII armor.
* *