1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-12-16 09:11:08 +01:00

Add SharedPGPCertificateDirectoryAdapter class

This commit is contained in:
Paul Schaub 2022-01-31 16:51:27 +01:00
parent 50243aa6b6
commit 3bc613f2ea
10 changed files with 236 additions and 38 deletions

View file

@ -0,0 +1,10 @@
<!--
SPDX-FileCopyrightText: 2022 Paul Schaub <info@pgpainless.org>
SPDX-License-Identifier: Apache-2.0
-->
# PGP Certificate Store Definitions
This module contains API definitions for a certificate store for PGPainless.
A certificate store is used to store public key certificates only.

View file

@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.certificate_store;
import java.io.IOException;
import java.io.InputStream;
/**
* Interface definition for a class that can read {@link Certificate Certificates} from binary
* {@link InputStream InputStreams}.
*/
public interface CertificateReaderBackend {
/**
* Read a {@link Certificate} from the given {@link InputStream}.
*
* @param inputStream input stream containing the binary representation of the certificate.
* @return certificate object
*
* @throws IOException in case of an IO error
*/
Certificate readCertificate(InputStream inputStream) throws IOException;
}

View file

@ -8,21 +8,46 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
/**
* Certificate storage definition.
* This interface defines methods to insert and retrieve {@link Certificate Certificates} to and from a store.
*
* {@link Certificate Certificates} are hereby identified by identifiers. An identifier can either be a fingerprint
* or a special name. Special names are implementation-defined identifiers for certificates.
*
* Fingerprints are expected to be hexadecimal lowercase character sequences.
*/
public interface CertificateStore {
Certificate get(String identifier) throws IOException;
/**
* Return the certificate that matches the given identifier.
* If no matching certificate can be found, return null.
*
* @param identifier identifier for a certificate.
* @return certificate or null
*
* @throws IOException in case of an IO-error
*/
Certificate getCertificate(String identifier) throws IOException;
Certificate getIfChanged(String identifier, String tag) throws IOException;
/**
*
* @param identifier
* @param tag
* @return
* @throws IOException
*/
Certificate getCertificateIfChanged(String identifier, String tag) throws IOException;
Certificate insert(InputStream data, MergeCallback merge) throws IOException;
Certificate insertCertificate(InputStream data, MergeCallback merge) throws IOException, InterruptedException;
Certificate tryInsert(InputStream data, MergeCallback merge) throws IOException;
Certificate tryInsertCertificate(InputStream data, MergeCallback merge) throws IOException;
Certificate insertSpecial(String specialName, InputStream data, MergeCallback merge) throws IOException;
Certificate insertCertificateBySpecialName(String specialName, InputStream data, MergeCallback merge) throws IOException, InterruptedException;
Certificate tryInsertSpecial(String specialName, InputStream data, MergeCallback merge) throws IOException;
Certificate tryInsertCertificateBySpecialName(String specialName, InputStream data, MergeCallback merge) throws IOException;
Iterator<Certificate> items();
Iterator<Certificate> getCertificates();
Iterator<String> fingerprints();
Iterator<String> getFingerprints();
}

View file

@ -1,14 +0,0 @@
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package pgp.certificate_store;
import java.io.IOException;
import java.io.InputStream;
public interface ParserBackend {
Certificate readCertificate(InputStream inputStream) throws IOException;
}