Get rid of certificate-store abstraction

This commit is contained in:
Paul Schaub 2022-08-09 18:00:27 +02:00
parent 7c39781d15
commit 7cc0ef5037
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
30 changed files with 31 additions and 399 deletions

View file

@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d;
/**
* The data was not a valid OpenPGP cert or key in binary format.
*/
public class BadDataException extends Exception {
}

View file

@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d;
/**
* Provided name was neither a valid fingerprint, nor a known special name.
*/
public class BadNameException extends Exception {
public BadNameException() {
super();
}
public BadNameException(String message) {
super(message);
}
}

View file

@ -4,13 +4,10 @@
package pgp.cert_d;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.KeyMaterial;
import pgp.certificate_store.KeyMaterialMerger;
import pgp.certificate_store.KeyMaterialReaderBackend;
import pgp.certificate_store.exception.BadDataException;
import pgp.certificate_store.exception.BadNameException;
import pgp.certificate_store.exception.NotAStoreException;
import pgp.certificate.Certificate;
import pgp.certificate.KeyMaterial;
import pgp.certificate.KeyMaterialMerger;
import pgp.certificate.KeyMaterialReaderBackend;
import java.io.BufferedInputStream;
import java.io.File;

View file

@ -4,12 +4,10 @@
package pgp.cert_d;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.KeyMaterial;
import pgp.certificate_store.KeyMaterialMerger;
import pgp.certificate_store.KeyMaterialReaderBackend;
import pgp.certificate_store.exception.BadDataException;
import pgp.certificate_store.exception.BadNameException;
import pgp.certificate.Certificate;
import pgp.certificate.KeyMaterial;
import pgp.certificate.KeyMaterialMerger;
import pgp.certificate.KeyMaterialReaderBackend;
import java.io.IOException;
import java.io.InputStream;

View file

@ -11,8 +11,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import pgp.certificate_store.SubkeyLookup;
public class InMemorySubkeyLookup implements SubkeyLookup {
private static final Map<Long, Set<String>> subkeyMap = new HashMap<>();

View file

@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d;
/**
* The base dir cannot possibly contain a store.
*/
public class NotAStoreException extends Exception {
public NotAStoreException() {
super();
}
public NotAStoreException(String message) {
super(message);
}
}

View file

@ -4,8 +4,7 @@
package pgp.cert_d;
import pgp.certificate_store.KeyMaterialReaderBackend;
import pgp.certificate_store.exception.NotAStoreException;
import pgp.certificate.KeyMaterialReaderBackend;
import java.io.File;

View file

@ -4,11 +4,9 @@
package pgp.cert_d;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.KeyMaterial;
import pgp.certificate_store.KeyMaterialMerger;
import pgp.certificate_store.exception.BadDataException;
import pgp.certificate_store.exception.BadNameException;
import pgp.certificate.Certificate;
import pgp.certificate.KeyMaterial;
import pgp.certificate.KeyMaterialMerger;
import java.io.IOException;
import java.io.InputStream;

View file

@ -4,9 +4,7 @@
package pgp.cert_d;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.exception.BadDataException;
import pgp.certificate_store.exception.BadNameException;
import pgp.certificate.Certificate;
import java.io.IOException;
import java.util.Iterator;

View file

@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.cert_d;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public interface SubkeyLookup {
/**
* Lookup the fingerprint of the certificate that contains the given subkey.
* If no record is found, return null.
*
* @param subkeyId subkey id
* @return fingerprint of the certificate
*
* @throws IOException in case of an IO error
*/
Set<String> getCertificateFingerprintsForSubkeyId(long subkeyId) throws IOException;
/**
* Record, which certificate the subkey-ids in the list belong to.
* This method does not change the affiliation of subkey-ids not contained in the provided list.
*
* @param certificate certificate fingerprint
* @param subkeyIds subkey ids
*
* @throws IOException in case of an IO error
*/
void storeCertificateSubkeyIds(String certificate, List<Long> subkeyIds) throws IOException;
}

View file

@ -4,11 +4,9 @@
package pgp.cert_d;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.KeyMaterial;
import pgp.certificate_store.KeyMaterialMerger;
import pgp.certificate_store.exception.BadDataException;
import pgp.certificate_store.exception.BadNameException;
import pgp.certificate.Certificate;
import pgp.certificate.KeyMaterial;
import pgp.certificate.KeyMaterialMerger;
import java.io.IOException;
import java.io.InputStream;