2022-08-09 17:50:15 +02:00
|
|
|
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package pgp.cert_d;
|
|
|
|
|
2022-08-11 21:50:02 +02:00
|
|
|
import pgp.cert_d.backend.FileBasedCertificateDirectoryBackend;
|
|
|
|
import pgp.cert_d.backend.InMemoryCertificateDirectoryBackend;
|
2022-08-12 14:10:09 +02:00
|
|
|
import pgp.cert_d.subkey_lookup.InMemorySubkeyLookup;
|
|
|
|
import pgp.cert_d.subkey_lookup.SubkeyLookup;
|
|
|
|
import pgp.certificate_store.certificate.KeyMaterialReaderBackend;
|
|
|
|
import pgp.certificate_store.exception.NotAStoreException;
|
2022-08-09 17:50:15 +02:00
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
2022-08-23 15:19:01 +02:00
|
|
|
/**
|
|
|
|
* Static factory methods that return implementations of the {@link PGPCertificateDirectory} class.
|
|
|
|
*/
|
2022-08-09 17:50:15 +02:00
|
|
|
public final class PGPCertificateDirectories {
|
|
|
|
|
|
|
|
private PGPCertificateDirectories() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-23 15:19:01 +02:00
|
|
|
public static PGPCertificateDirectory inMemoryCertificateDirectory(
|
|
|
|
KeyMaterialReaderBackend keyReader) {
|
|
|
|
return new PGPCertificateDirectory(
|
|
|
|
new InMemoryCertificateDirectoryBackend(keyReader), new InMemorySubkeyLookup());
|
2022-08-09 17:50:15 +02:00
|
|
|
}
|
|
|
|
|
2022-08-23 15:19:01 +02:00
|
|
|
public static PGPCertificateDirectory defaultFileBasedCertificateDirectory(
|
|
|
|
KeyMaterialReaderBackend keyReader,
|
|
|
|
SubkeyLookup subkeyLookup)
|
2022-08-09 17:50:15 +02:00
|
|
|
throws NotAStoreException {
|
2022-08-12 14:10:09 +02:00
|
|
|
return fileBasedCertificateDirectory(keyReader, BaseDirectoryProvider.getDefaultBaseDir(), subkeyLookup);
|
2022-08-09 17:50:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static PGPCertificateDirectory fileBasedCertificateDirectory(
|
2022-08-23 15:19:01 +02:00
|
|
|
KeyMaterialReaderBackend keyReader,
|
|
|
|
File baseDirectory,
|
|
|
|
SubkeyLookup subkeyLookup)
|
2022-08-09 17:50:15 +02:00
|
|
|
throws NotAStoreException {
|
|
|
|
return new PGPCertificateDirectory(
|
2022-08-12 14:10:09 +02:00
|
|
|
new FileBasedCertificateDirectoryBackend(baseDirectory, keyReader), subkeyLookup);
|
2022-08-09 17:50:15 +02:00
|
|
|
}
|
|
|
|
}
|