From 7cc0ef5037b631b3bcef04811682b4e7b988fb7e Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Tue, 9 Aug 2022 18:00:27 +0200 Subject: [PATCH] Get rid of certificate-store abstraction --- .../jdbc/sqlite/DatabaseSubkeyLookup.java | 2 +- .../pgp/cert_d/jdbc/sqlite/package-info.java | 2 +- pgp-cert-d-java/build.gradle | 3 - .../java/pgp/cert_d}/BadDataException.java | 2 +- .../java/pgp/cert_d}/BadNameException.java | 2 +- .../FileBasedCertificateDirectoryBackend.java | 11 +- .../InMemoryCertificateDirectoryBackend.java | 10 +- .../java/pgp/cert_d/InMemorySubkeyLookup.java | 2 - .../java/pgp/cert_d}/NotAStoreException.java | 2 +- .../pgp/cert_d/PGPCertificateDirectories.java | 3 +- .../pgp/cert_d/PGPCertificateDirectory.java | 8 +- .../ReadOnlyPGPCertificateDirectory.java | 4 +- .../main/java/pgp/cert_d}/SubkeyLookup.java | 2 +- .../WritingPGPCertificateDirectory.java | 8 +- .../java/pgp/certificate}/Certificate.java | 2 +- .../src/main/java/pgp/certificate}/Key.java | 2 +- .../java/pgp/certificate}/KeyMaterial.java | 2 +- .../pgp/certificate}/KeyMaterialMerger.java | 2 +- .../KeyMaterialReaderBackend.java | 4 +- .../java/pgp/certificate}/package-info.java | 4 +- .../java/pgp/cert_d/FilenameResolverTest.java | 1 - .../java/pgp/cert_d/SubkeyLookupTest.java | 1 - pgp-certificate-store/README.md | 13 - pgp-certificate-store/build.gradle | 36 --- .../AbstractCertificateStore.java | 39 --- .../CertificateDirectory.java | 225 ------------------ .../certificate_store/CertificateStore.java | 9 - .../exception/package-info.java | 10 - .../java/pgp/certificate_store/DummyTest.java | 16 -- settings.gradle | 3 +- 30 files changed, 31 insertions(+), 399 deletions(-) rename {pgp-certificate-store/src/main/java/pgp/certificate_store/exception => pgp-cert-d-java/src/main/java/pgp/cert_d}/BadDataException.java (85%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store/exception => pgp-cert-d-java/src/main/java/pgp/cert_d}/BadNameException.java (90%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store/exception => pgp-cert-d-java/src/main/java/pgp/cert_d}/NotAStoreException.java (89%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/cert_d}/SubkeyLookup.java (97%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/Certificate.java (90%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/Key.java (93%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/KeyMaterial.java (96%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/KeyMaterialMerger.java (96%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/KeyMaterialReaderBackend.java (89%) rename {pgp-certificate-store/src/main/java/pgp/certificate_store => pgp-cert-d-java/src/main/java/pgp/certificate}/package-info.java (57%) delete mode 100644 pgp-certificate-store/README.md delete mode 100644 pgp-certificate-store/build.gradle delete mode 100644 pgp-certificate-store/src/main/java/pgp/certificate_store/AbstractCertificateStore.java delete mode 100644 pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateDirectory.java delete mode 100644 pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateStore.java delete mode 100644 pgp-certificate-store/src/main/java/pgp/certificate_store/exception/package-info.java delete mode 100644 pgp-certificate-store/src/test/java/pgp/certificate_store/DummyTest.java diff --git a/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/DatabaseSubkeyLookup.java b/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/DatabaseSubkeyLookup.java index f35d7c8..5e3b58e 100644 --- a/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/DatabaseSubkeyLookup.java +++ b/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/DatabaseSubkeyLookup.java @@ -11,7 +11,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import pgp.certificate_store.SubkeyLookup; +import pgp.cert_d.SubkeyLookup; public class DatabaseSubkeyLookup implements SubkeyLookup { diff --git a/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/package-info.java b/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/package-info.java index cf7f9af..08114e4 100644 --- a/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/package-info.java +++ b/pgp-cert-d-java-jdbc-sqlite-lookup/src/main/java/pgp/cert_d/jdbc/sqlite/package-info.java @@ -3,6 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 /** - * Implementation of a {@link pgp.certificate_store.SubkeyLookup} mechanism using an SQLite Database. + * Implementation of a {@link pgp.cert_d.SubkeyLookup} mechanism using an SQLite Database. */ package pgp.cert_d.jdbc.sqlite; diff --git a/pgp-cert-d-java/build.gradle b/pgp-cert-d-java/build.gradle index db5ba5c..9513682 100644 --- a/pgp-cert-d-java/build.gradle +++ b/pgp-cert-d-java/build.gradle @@ -28,9 +28,6 @@ dependencies { // SQL Subkey table testImplementation project(":pgp-cert-d-java-jdbc-sqlite-lookup") - - // Certificate store - api project(":pgp-certificate-store") } animalsniffer { diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadDataException.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/BadDataException.java similarity index 85% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadDataException.java rename to pgp-cert-d-java/src/main/java/pgp/cert_d/BadDataException.java index 3bb7019..6dbbcde 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadDataException.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/BadDataException.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store.exception; +package pgp.cert_d; /** * The data was not a valid OpenPGP cert or key in binary format. diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadNameException.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/BadNameException.java similarity index 90% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadNameException.java rename to pgp-cert-d-java/src/main/java/pgp/cert_d/BadNameException.java index 957126e..4386506 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/BadNameException.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/BadNameException.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store.exception; +package pgp.cert_d; /** * Provided name was neither a valid fingerprint, nor a known special name. diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/FileBasedCertificateDirectoryBackend.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/FileBasedCertificateDirectoryBackend.java index 8b112cb..469457f 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/FileBasedCertificateDirectoryBackend.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/FileBasedCertificateDirectoryBackend.java @@ -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; diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemoryCertificateDirectoryBackend.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemoryCertificateDirectoryBackend.java index fe7cc89..ff7c401 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemoryCertificateDirectoryBackend.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemoryCertificateDirectoryBackend.java @@ -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; diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemorySubkeyLookup.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemorySubkeyLookup.java index ec67ee0..400b0c1 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemorySubkeyLookup.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/InMemorySubkeyLookup.java @@ -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> subkeyMap = new HashMap<>(); diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/NotAStoreException.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/NotAStoreException.java similarity index 89% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/exception/NotAStoreException.java rename to pgp-cert-d-java/src/main/java/pgp/cert_d/NotAStoreException.java index a19aa9c..4abd1f0 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/NotAStoreException.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/NotAStoreException.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store.exception; +package pgp.cert_d; /** * The base dir cannot possibly contain a store. diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectories.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectories.java index b75ac43..de185b0 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectories.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectories.java @@ -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; diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectory.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectory.java index ef7fc5d..f3a753d 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectory.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/PGPCertificateDirectory.java @@ -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; diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/ReadOnlyPGPCertificateDirectory.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/ReadOnlyPGPCertificateDirectory.java index 07ad7de..03a563b 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/ReadOnlyPGPCertificateDirectory.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/ReadOnlyPGPCertificateDirectory.java @@ -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; diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/SubkeyLookup.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/SubkeyLookup.java similarity index 97% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/SubkeyLookup.java rename to pgp-cert-d-java/src/main/java/pgp/cert_d/SubkeyLookup.java index 55d03e6..58101bd 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/SubkeyLookup.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/SubkeyLookup.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.cert_d; import java.io.IOException; import java.util.List; diff --git a/pgp-cert-d-java/src/main/java/pgp/cert_d/WritingPGPCertificateDirectory.java b/pgp-cert-d-java/src/main/java/pgp/cert_d/WritingPGPCertificateDirectory.java index 2ac60f7..57ce4c8 100644 --- a/pgp-cert-d-java/src/main/java/pgp/cert_d/WritingPGPCertificateDirectory.java +++ b/pgp-cert-d-java/src/main/java/pgp/cert_d/WritingPGPCertificateDirectory.java @@ -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; diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/Certificate.java b/pgp-cert-d-java/src/main/java/pgp/certificate/Certificate.java similarity index 90% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/Certificate.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/Certificate.java index 444f2ee..969064d 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/Certificate.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/Certificate.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.certificate; /** * OpenPGP certificate (public key). diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/Key.java b/pgp-cert-d-java/src/main/java/pgp/certificate/Key.java similarity index 93% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/Key.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/Key.java index 75a93f6..80c9636 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/Key.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/Key.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.certificate; /** * OpenPGP key (secret key). diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterial.java b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterial.java similarity index 96% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterial.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterial.java index 7edce0c..87c309e 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterial.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterial.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.certificate; import java.io.IOException; import java.io.InputStream; diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialMerger.java b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialMerger.java similarity index 96% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialMerger.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialMerger.java index 4cef3c8..bd70bc8 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialMerger.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialMerger.java @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.certificate; import java.io.IOException; diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialReaderBackend.java b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialReaderBackend.java similarity index 89% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialReaderBackend.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialReaderBackend.java index c45f774..b1996f9 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/KeyMaterialReaderBackend.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/KeyMaterialReaderBackend.java @@ -2,9 +2,9 @@ // // SPDX-License-Identifier: Apache-2.0 -package pgp.certificate_store; +package pgp.certificate; -import pgp.certificate_store.exception.BadDataException; +import pgp.cert_d.BadDataException; import java.io.IOException; import java.io.InputStream; diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/package-info.java b/pgp-cert-d-java/src/main/java/pgp/certificate/package-info.java similarity index 57% rename from pgp-certificate-store/src/main/java/pgp/certificate_store/package-info.java rename to pgp-cert-d-java/src/main/java/pgp/certificate/package-info.java index 39164d4..ac5b0f4 100644 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/package-info.java +++ b/pgp-cert-d-java/src/main/java/pgp/certificate/package-info.java @@ -3,6 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 /** - * Abstract definitions of an OpenPGP certificate store. + * General OpenPGP Certificate Storage related classes. */ -package pgp.certificate_store; +package pgp.certificate; diff --git a/pgp-cert-d-java/src/test/java/pgp/cert_d/FilenameResolverTest.java b/pgp-cert-d-java/src/test/java/pgp/cert_d/FilenameResolverTest.java index ee617b3..513bcad 100644 --- a/pgp-cert-d-java/src/test/java/pgp/cert_d/FilenameResolverTest.java +++ b/pgp-cert-d-java/src/test/java/pgp/cert_d/FilenameResolverTest.java @@ -6,7 +6,6 @@ package pgp.cert_d; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import pgp.certificate_store.exception.BadNameException; import java.io.File; import java.io.IOException; diff --git a/pgp-cert-d-java/src/test/java/pgp/cert_d/SubkeyLookupTest.java b/pgp-cert-d-java/src/test/java/pgp/cert_d/SubkeyLookupTest.java index 03ad9c8..979f190 100644 --- a/pgp-cert-d-java/src/test/java/pgp/cert_d/SubkeyLookupTest.java +++ b/pgp-cert-d-java/src/test/java/pgp/cert_d/SubkeyLookupTest.java @@ -24,7 +24,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import pgp.cert_d.jdbc.sqlite.DatabaseSubkeyLookup; import pgp.cert_d.jdbc.sqlite.SqliteSubkeyLookupDaoImpl; -import pgp.certificate_store.SubkeyLookup; public class SubkeyLookupTest { diff --git a/pgp-certificate-store/README.md b/pgp-certificate-store/README.md deleted file mode 100644 index 58f9af9..0000000 --- a/pgp-certificate-store/README.md +++ /dev/null @@ -1,13 +0,0 @@ - - -# PGP Certificate Store Definitions - -[![javadoc](https://javadoc.io/badge2/org.pgpainless/pgp-certificate-store/javadoc.svg)](https://javadoc.io/doc/org.pgpainless/pgp-certificate-store) -[![Maven Central](https://badgen.net/maven/v/maven-central/org.pgpainless/pgp-certificate-store)](https://search.maven.org/artifact/org.pgpainless/pgp-certificate-store) - -This module contains API definitions for an OpenPGP certificate store. -A certificate store is used to store public key certificates only. diff --git a/pgp-certificate-store/build.gradle b/pgp-certificate-store/build.gradle deleted file mode 100644 index f2d7d7a..0000000 --- a/pgp-certificate-store/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: 2021 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -plugins { - id 'java-library' -} - -group 'org.pgpainless' - -repositories { - mavenCentral() -} - -apply plugin: 'ru.vyarus.animalsniffer' - -dependencies { - // animal sniffer for ensuring Android API compatibility - signature "net.sf.androidscents.signature:android-api-level-${minAndroidSdk}:2.3.3_r2@signature" - - // JUnit for testing - testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" - testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" - - // Logging - api "org.slf4j:slf4j-api:$slf4jVersion" - testImplementation "ch.qos.logback:logback-classic:$logbackVersion" -} - -animalsniffer { - sourceSets = [sourceSets.main] -} - -test { - useJUnitPlatform() -} diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/AbstractCertificateStore.java b/pgp-certificate-store/src/main/java/pgp/certificate_store/AbstractCertificateStore.java deleted file mode 100644 index 3bd394e..0000000 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/AbstractCertificateStore.java +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -package pgp.certificate_store; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pgp.certificate_store.exception.BadDataException; -import pgp.certificate_store.exception.BadNameException; - -import java.io.IOException; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -public abstract class AbstractCertificateStore implements CertificateStore { - - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCertificateStore.class); - - public Set getCertificatesBySubkeyId(long subkeyId) - throws IOException { - Set identifiers = getCertificateFingerprintsForSubkeyId(subkeyId); - if (identifiers.isEmpty()) { - return Collections.emptySet(); - } - - Set certificates = new HashSet<>(); - for (String identifier : identifiers) { - try { - certificates.add(getCertificate(identifier)); - } catch (BadNameException | BadDataException e) { - LOGGER.warn("Could not read certificate.", e); - } - } - - return certificates; - } -} diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateDirectory.java b/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateDirectory.java deleted file mode 100644 index 1bb9eb8..0000000 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateDirectory.java +++ /dev/null @@ -1,225 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -package pgp.certificate_store; - -import pgp.certificate_store.exception.BadDataException; -import pgp.certificate_store.exception.BadNameException; - -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 CertificateDirectory { - - /** - * 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 - * @throws BadNameException if the identifier is invalid - * @throws BadDataException if the certificate file contains invalid data - */ - Certificate getCertificate(String identifier) - throws IOException, BadNameException, BadDataException; - - /** - * Return the certificate that matches the given identifier, but only iff it changed since the last invocation. - * To compare the certificate against its last returned result, the given tag is used. - * If the tag of the currently found certificate matches the given argument, return null. - * - * @param identifier identifier for a certificate - * @param tag tag to compare freshness - * @return changed certificate or null - * - * @throws IOException in case of an IO-error - * @throws BadNameException if the identifier is invalid - * @throws BadDataException if the certificate file contains invalid data - */ - Certificate getCertificateIfChanged(String identifier, String tag) - throws IOException, BadNameException, BadDataException; - - /** - * Insert a certificate into the store. - * If an instance of the certificate is already present in the store, the given {@link KeyMaterialMerger} will be - * used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate - * will be stored in the store and returned. - * - * This method will block until a write-lock on the store can be acquired. If you cannot afford blocking, - * consider to use {@link #tryInsertCertificate(InputStream, KeyMaterialMerger)} instead. - * - * @param data input stream containing the new certificate instance - * @param merge callback for merging with an existing certificate instance - * @return merged certificate - * - * @throws IOException in case of an IO-error - * @throws InterruptedException in case the inserting thread gets interrupted - * @throws BadDataException if the data stream does not contain valid OpenPGP data - */ - Certificate insertCertificate(InputStream data, KeyMaterialMerger merge) - throws IOException, InterruptedException, BadDataException; - - /** - * Insert a certificate into the store. - * If an instance of the certificate is already present in the store, the given {@link KeyMaterialMerger} will be - * used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate - * will be stored in the store and returned. - * - * This method will not block. Instead, if the store is already write-locked, this method will simply return null - * without any writing. - * However, if the write-lock is available, this method will acquire the lock, write to the store, release the lock - * and return the written certificate. - * - * @param data input stream containing the new certificate instance - * @param merge callback for merging with an existing certificate instance - * @return merged certificate or null if the store cannot be locked - * - * @throws IOException in case of an IO-error - * @throws BadDataException if the data stream does not contain valid OpenPGP data - */ - Certificate tryInsertCertificate(InputStream data, KeyMaterialMerger merge) - throws IOException, BadDataException; - - /** - * Insert a certificate into the store. - * The certificate will be stored under the given special name instead of its fingerprint. - * - * If an instance of the certificate is already present under the special name in the store, the given {@link KeyMaterialMerger} will be - * used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate - * will be stored in the store and returned. - * - * This method will block until a write-lock on the store can be acquired. If you cannot afford blocking, - * consider to use {@link #tryInsertCertificateBySpecialName(String, InputStream, KeyMaterialMerger)} instead. - * - * @param specialName special name of the certificate - * @param data input stream containing the new certificate instance - * @param merge callback for merging with an existing certificate instance - * @return merged certificate or null if the store cannot be locked - * - * @throws IOException in case of an IO-error - * @throws InterruptedException if the thread is interrupted - * @throws BadDataException if the certificate file does not contain valid OpenPGP data - * @throws BadNameException if the special name is unknown - */ - Certificate insertCertificateBySpecialName(String specialName, InputStream data, KeyMaterialMerger merge) - throws IOException, InterruptedException, BadDataException, BadNameException; - - /** - * Insert a certificate into the store. - * The certificate will be stored under the given special name instead of its fingerprint. - * - * If an instance of the certificate is already present under the special name in the store, the given {@link KeyMaterialMerger} will be - * used to merge both the existing and the new instance of the {@link Certificate}. The resulting merged certificate - * will be stored in the store and returned. - * - * This method will not block. Instead, if the store is already write-locked, this method will simply return null - * without any writing. - * However, if the write-lock is available, this method will acquire the lock, write to the store, release the lock - * and return the written certificate. - * - * @param specialName special name for the certificate - * @param data input stream containing the new certificate instance - * @param merge callback for merging with an existing certificate instance - * @return merged certificate or null if the store cannot be locked - * - * @throws IOException in case of an IO-error - * @throws BadDataException if the data stream does not contain valid OpenPGP data - * @throws BadNameException if the special name is not known - */ - Certificate tryInsertCertificateBySpecialName(String specialName, InputStream data, KeyMaterialMerger merge) - throws IOException, BadDataException, BadNameException; - - /** - * Return an {@link Iterator} containing all certificates in the store. - * The iterator will contain both certificates addressed by special names and by fingerprints. - * - * @return certificates - */ - Iterator getCertificates(); - - /** - * Return an {@link Iterator} containing all certificate fingerprints from the store. - * Note that this only includes the fingerprints of certificate primary keys, not those of subkeys. - * - * @return fingerprints - */ - Iterator getFingerprints(); - - /** - * Return the current trust-root key. - * If no trust-root key is present, return null. - * - * @return trust-root key - * - * @throws IOException in case of an IO error - * @throws BadDataException if the key datum contains invalid data - */ - Key getTrustRoot() - throws IOException, BadDataException; - - /** - * Return the current trust-root key, but only iff it changed since the last invocation of this method. - * To compare the key against its last returned result, the given tag is used. - * If the tag of the currently found key matches the given argument, return null. - * - * @param tag tag to compare freshness - * @return changed key or null - * - * @throws IOException in case of an IO error - * @throws BadDataException if the key datum contains invalid data - */ - Key getTrustRootIfChanged(String tag) - throws IOException, BadDataException; - - /** - * Insert the given trust-root key into the store. - * If the key store already holds a trust-root key, the given {@link KeyMaterialMerger} callback will be used to merge - * the two instances into one {@link Key}. The result will be stored in the store and returned. - * - * This method will not block. Instead, if the store is already write-locked, this method will simply return null - * without writing anything. - * However, if the write-lock is available, this method will acquire the lock, write to the store, release the lock - * and return the written key. - * - * @param data input stream containing the new trust-root key - * @param keyMerger callback for merging with an existing key instance - * @return merged key - * - * @throws IOException in case of an IO error - * @throws InterruptedException in case the inserting thread gets interrupted - * @throws BadDataException if the data stream does not contain a valid OpenPGP key - */ - Key insertTrustRoot(InputStream data, KeyMaterialMerger keyMerger) - throws IOException, InterruptedException, BadDataException; - - /** - * Insert the given trust-root key into the store. - * If the key store already holds a trust-root key, the given {@link KeyMaterialMerger} callback will be used to merge - * the two instances into one {@link Key}. The result will be stored in the store and returned. - * - * This method will block until a write-lock on the store can be acquired. If you cannot afford blocking, - * consider using {@link #tryInsertTrustRoot(InputStream, KeyMaterialMerger)} instead. - * - * @param data input stream containing the new trust-root key - * @param keyMerger callback for merging with an existing key instance - * @return merged key - * - * @throws IOException in case of an IO error - * @throws BadDataException if the data stream does not contain a valid OpenPGP key - */ - Key tryInsertTrustRoot(InputStream data, KeyMaterialMerger keyMerger) - throws IOException, BadDataException; -} diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateStore.java b/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateStore.java deleted file mode 100644 index a8325ee..0000000 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/CertificateStore.java +++ /dev/null @@ -1,9 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -package pgp.certificate_store; - -public interface CertificateStore extends CertificateDirectory, SubkeyLookup { - -} diff --git a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/package-info.java b/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/package-info.java deleted file mode 100644 index c06ce06..0000000 --- a/pgp-certificate-store/src/main/java/pgp/certificate_store/exception/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -/** - * Exceptions defined by the Shared PGP Certificate Directory. - * - * @see Failure Modes - */ -package pgp.certificate_store.exception; diff --git a/pgp-certificate-store/src/test/java/pgp/certificate_store/DummyTest.java b/pgp-certificate-store/src/test/java/pgp/certificate_store/DummyTest.java deleted file mode 100644 index e766c29..0000000 --- a/pgp-certificate-store/src/test/java/pgp/certificate_store/DummyTest.java +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: 2022 Paul Schaub -// -// SPDX-License-Identifier: Apache-2.0 - -package pgp.certificate_store; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class DummyTest { - @Test - public void test() { - assertTrue(true); - } -} diff --git a/settings.gradle b/settings.gradle index 3920c69..39451e2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -5,6 +5,5 @@ rootProject.name = 'cert-d-java' include 'pgp-cert-d-java', - 'pgp-cert-d-java-jdbc-sqlite-lookup', - 'pgp-certificate-store' + 'pgp-cert-d-java-jdbc-sqlite-lookup'