mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-07 21:01:16 +01:00
Revert certificate-store integration
Integration of certificate-store and pgpainless-cert-d makes packaging complicated. Alternatively, users can simply integrate the certificate-store with PGPainless themselves.
This commit is contained in:
parent
7a2c9d864c
commit
8cb773841b
5 changed files with 0 additions and 305 deletions
|
|
@ -6,12 +6,10 @@ package org.pgpainless.decryption_verification;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -25,7 +23,6 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.PGPSignature;
|
||||
import org.bouncycastle.openpgp.operator.PublicKeyDataDecryptorFactory;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.decryption_verification.cleartext_signatures.InMemoryMultiPassStrategy;
|
||||
import org.pgpainless.decryption_verification.cleartext_signatures.MultiPassStrategy;
|
||||
import org.pgpainless.key.SubkeyIdentifier;
|
||||
|
|
@ -33,9 +30,6 @@ import org.pgpainless.key.protection.SecretKeyRingProtector;
|
|||
import org.pgpainless.signature.SignatureUtils;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import org.pgpainless.util.SessionKey;
|
||||
import pgp.certificate_store.PGPCertificateStore;
|
||||
import pgp.certificate_store.certificate.Certificate;
|
||||
import pgp.certificate_store.exception.BadDataException;
|
||||
|
||||
/**
|
||||
* Options for decryption and signature verification.
|
||||
|
|
@ -135,17 +129,6 @@ public class ConsumerOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass in a {@link PGPCertificateStore} from which certificates can be sourced for signature verification.
|
||||
*
|
||||
* @param certificateStore certificate store
|
||||
* @return options
|
||||
*/
|
||||
public ConsumerOptions addVerificationCerts(PGPCertificateStore certificateStore) {
|
||||
this.certificates.addStore(certificateStore);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add some detached signatures from the given {@link InputStream} for verification.
|
||||
*
|
||||
|
|
@ -484,18 +467,8 @@ public class ConsumerOptions {
|
|||
*/
|
||||
public static class CertificateSource {
|
||||
|
||||
private List<PGPCertificateStore> stores = new ArrayList<>();
|
||||
private Set<PGPPublicKeyRing> explicitCertificates = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Add a certificate store as source for verification certificates.
|
||||
*
|
||||
* @param certificateStore cert store
|
||||
*/
|
||||
public void addStore(PGPCertificateStore certificateStore) {
|
||||
this.stores.add(certificateStore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a certificate as verification cert explicitly.
|
||||
*
|
||||
|
|
@ -529,19 +502,6 @@ public class ConsumerOptions {
|
|||
}
|
||||
}
|
||||
|
||||
for (PGPCertificateStore store : stores) {
|
||||
try {
|
||||
Iterator<Certificate> certs = store.getCertificatesBySubkeyId(keyId);
|
||||
if (!certs.hasNext()) {
|
||||
continue;
|
||||
}
|
||||
Certificate cert = certs.next();
|
||||
PGPPublicKeyRing publicKey = PGPainless.readKeyRing().publicKeyRing(cert.getInputStream());
|
||||
return publicKey;
|
||||
} catch (IOException | BadDataException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package org.pgpainless.encryption_signing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -14,7 +13,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
|
|
@ -22,7 +20,6 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
|||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.operator.PBEKeyEncryptionMethodGenerator;
|
||||
import org.bouncycastle.openpgp.operator.PGPKeyEncryptionMethodGenerator;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
|
||||
import org.pgpainless.exception.KeyException;
|
||||
|
|
@ -32,10 +29,6 @@ import org.pgpainless.key.SubkeyIdentifier;
|
|||
import org.pgpainless.key.info.KeyAccessor;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
import pgp.certificate_store.PGPCertificateStore;
|
||||
import pgp.certificate_store.certificate.Certificate;
|
||||
import pgp.certificate_store.exception.BadDataException;
|
||||
import pgp.certificate_store.exception.BadNameException;
|
||||
|
||||
/**
|
||||
* Options for the encryption process.
|
||||
|
|
@ -241,28 +234,6 @@ public class EncryptionOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a recipient by providing a {@link PGPCertificateStore} and the {@link OpenPgpFingerprint} of the recipients key.
|
||||
* If no such certificate is found in the store, a {@link NoSuchElementException is thrown}.
|
||||
*
|
||||
* @param certificateStore certificate store
|
||||
* @param certificateFingerprint fingerprint of the recipient certificate
|
||||
* @return builder
|
||||
* @throws BadDataException if the certificate contains bad data
|
||||
* @throws BadNameException if the fingerprint is not in a recognizable form for the store
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws NoSuchElementException if the store does not contain a certificate for the given fingerprint
|
||||
*/
|
||||
public EncryptionOptions addRecipient(@Nonnull PGPCertificateStore certificateStore,
|
||||
@Nonnull OpenPgpFingerprint certificateFingerprint)
|
||||
throws BadDataException, BadNameException, IOException {
|
||||
String fingerprint = certificateFingerprint.toString().toLowerCase();
|
||||
Certificate certificateRecord = certificateStore.getCertificate(fingerprint);
|
||||
PGPPublicKeyRing recipientCertificate = PGPainless.readKeyRing()
|
||||
.publicKeyRing(certificateRecord.getInputStream());
|
||||
return addRecipient(recipientCertificate);
|
||||
}
|
||||
|
||||
private void addRecipientKey(PGPPublicKeyRing keyRing, PGPPublicKey key) {
|
||||
encryptionKeys.add(new SubkeyIdentifier(keyRing, key.getKeyID()));
|
||||
PGPKeyEncryptionMethodGenerator encryptionMethod = ImplementationFactory
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue