Compare commits

...

13 commits
0.1.1 ... main

Author SHA1 Message Date
5b6b2f0846
WKD-Java 0.1.3-SNAPSHOT 2023-07-07 12:40:36 +02:00
2a21833b19
WKD-Java 0.1.2 2023-07-07 12:38:07 +02:00
81d0c73adc
Bump jackson-databind to 2.15.2 2023-07-07 12:35:49 +02:00
873ca84af8
Bump PGPainless dependencies
Bump pgpainless-core to 1.5.6
Bump cert-d-pgpainless to 0.2.2
Bump cert-d-java to 0.2.2
2023-07-07 12:34:16 +02:00
df2e4fb61e
Update CHANGELOG 2022-11-25 16:19:40 +01:00
e9f2efd15a
Bump pgpainless-core to 1.3.12, pgpainless-cert-d to 0.2.1, cert-d-java to 0.2.1 2022-11-25 16:17:24 +01:00
f9543cddae
Fix NPE when fetching unfetchable cert 2022-09-13 12:31:26 +02:00
2a1676904f
Fix user-id format on test key 2022-08-04 13:26:46 +02:00
607518f945
Add support for i18n using resource bundles 2022-08-04 13:26:22 +02:00
55b08bcb25
Add badges for CI and Coveralls 2022-08-01 17:22:45 +02:00
5a8c886409
Add woodpecker CI 2022-08-01 17:17:21 +02:00
6fdce5b63f
Update changelog 2022-04-29 17:28:45 +02:00
cdd3d62c60
WKD-Java 0.1.2-SNAPSHOT 2022-04-29 17:26:17 +02:00
20 changed files with 108 additions and 29 deletions

View file

@ -13,3 +13,8 @@ Source: https://pgpainless.org
Files: gradle* Files: gradle*
Copyright: 2015 the original author or authors. Copyright: 2015 the original author or authors.
License: Apache-2.0 License: Apache-2.0
# Woodpecker build files
Files: .woodpecker/*
Copyright: 2022 the original author or authors.
License: Apache-2.0

12
.woodpecker/.build.yml Normal file
View file

@ -0,0 +1,12 @@
pipeline:
run:
image: gradle:7.5-jdk8
commands:
- git checkout $CI_COMMIT_BRANCH
# Code works
- gradle test
# Code is clean
- gradle check javadocAll
# Code has coverage
- gradle jacocoRootReport coveralls
secrets: [COVERALLS_REPO_TOKEN]

7
.woodpecker/.reuse.yml Normal file
View file

@ -0,0 +1,7 @@
# Code is licensed properly
# See https://reuse.software/
pipeline:
reuse:
image: fsfe/reuse:latest
commands:
- reuse lint

View file

@ -6,8 +6,14 @@ SPDX-License-Identifier: Apache-2.0
# Changelog # Changelog
## 0.1.2
- Bump `pgpainless-core` to `1.5.6`
- Bump `cert-d-pgpainless` to `0.2.2`
- Bump `cert-d-java` to `0.2.2`
## 0.1.1 ## 0.1.1
- Bump `pgpainless-core` to `1.2.1` - Bump `pgpainless-core` to `1.2.1`
- Bump `cert-d-pgpainless` to `0.1.2`
- Bump `pgp-certificate-store` to `0.1.1` - Bump `pgp-certificate-store` to `0.1.1`
- Bump `slf4j` to `1.7.36` - Bump `slf4j` to `1.7.36`
- Bump `logback` to `1.2.11` - Bump `logback` to `1.2.11`

View file

@ -6,6 +6,10 @@ SPDX-License-Identifier: Apache-2.0
# Web Key Directory for Java # Web Key Directory for Java
[![status-badge](https://ci.codeberg.org/api/badges/PGPainless/wkd-java/status.svg)](https://ci.codeberg.org/PGPainless/wkd-java)
[![Coverage Status](https://coveralls.io/repos/github/pgpainless/wkd-java/badge.svg?branch=main)](https://coveralls.io/github/pgpainless/wkd-java?branch=main)
[![REUSE status](https://api.reuse.software/badge/github.com/pgpainless/wkd-java)](https://api.reuse.software/info/github.com/pgpainless/wkd-java)
Client-side API for fetching OpenPGP certificates via the [Web Key Directory](https://www.ietf.org/archive/id/draft-koch-openpgp-webkey-service-13.html) protocol. Client-side API for fetching OpenPGP certificates via the [Web Key Directory](https://www.ietf.org/archive/id/draft-koch-openpgp-webkey-service-13.html) protocol.
## Modules ## Modules

View file

@ -4,22 +4,22 @@
allprojects { allprojects {
ext { ext {
shortVersion = '0.1.1' shortVersion = '0.1.3'
isSnapshot = false isSnapshot = true
minAndroidSdk = 10 minAndroidSdk = 10
javaSourceCompatibility = 1.8 javaSourceCompatibility = 1.8
jacksonDataBindVersion = '2.13.2.2' jacksonDataBindVersion = '2.15.2'
jacksonDataFormatXmlVersion = '2.13.2' jacksonDataFormatXmlVersion = '2.15.2'
junitVersion = '5.8.2' junitVersion = '5.8.2'
junitSysExitVersion = '1.1.2' junitSysExitVersion = '1.1.2'
jsrVersion = '3.0.2' jsrVersion = '3.0.2'
slf4jVersion = '1.7.36' slf4jVersion = '1.7.36'
logbackVersion = '1.2.11' logbackVersion = '1.2.11'
mockitoVersion = '4.5.1' mockitoVersion = '4.5.1'
pgpainlessVersion = '1.2.1' pgpainlessVersion = '1.5.6'
pgpainlessCertDVersion = '0.1.2' pgpainlessCertDVersion = '0.2.2'
picocliVersion = '4.6.3' picocliVersion = '4.6.3'
certDJavaVersion = '0.1.1' certDJavaVersion = '0.2.2'
zbase32Version = '1.0.0' zbase32Version = '1.0.0'
} }
} }

View file

@ -6,11 +6,11 @@ package pgp.wkd.cli;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.pgpainless.PGPainless; import org.pgpainless.PGPainless;
import org.pgpainless.certificate_store.CertificateFactory; import org.pgpainless.certificate_store.CertificateFactory;
import org.pgpainless.key.collection.PGPKeyRingCollection;
import org.pgpainless.key.info.KeyRingInfo; import org.pgpainless.key.info.KeyRingInfo;
import pgp.certificate_store.Certificate; import pgp.certificate_store.certificate.Certificate;
import pgp.wkd.CertificateAndUserIds; import pgp.wkd.CertificateAndUserIds;
import pgp.wkd.discovery.CertificateParser; import pgp.wkd.discovery.CertificateParser;
@ -24,10 +24,13 @@ public class PGPainlessCertificateParser implements CertificateParser {
public List<CertificateAndUserIds> read(InputStream inputStream) throws IOException { public List<CertificateAndUserIds> read(InputStream inputStream) throws IOException {
List<CertificateAndUserIds> certificatesAndUserIds = new ArrayList<>(); List<CertificateAndUserIds> certificatesAndUserIds = new ArrayList<>();
try { try {
PGPPublicKeyRingCollection certificates = PGPainless.readKeyRing().publicKeyRingCollection(inputStream); PGPKeyRingCollection keyMaterial = PGPainless.readKeyRing().keyRingCollection(inputStream, true);
for (PGPPublicKeyRing certificate : certificates) { if (keyMaterial.getPGPSecretKeyRingCollection().size() != 0) {
throw new PGPException("Secret key material encountered!");
}
for (PGPPublicKeyRing certificate : keyMaterial.getPgpPublicKeyRingCollection()) {
KeyRingInfo info = PGPainless.inspectKeyRing(certificate); KeyRingInfo info = PGPainless.inspectKeyRing(certificate);
Certificate parsedCert = CertificateFactory.certificateFromPublicKeyRing(certificate); Certificate parsedCert = CertificateFactory.certificateFromPublicKeyRing(certificate, 0L);
List<String> userIds = info.getValidAndExpiredUserIds(); List<String> userIds = info.getValidAndExpiredUserIds();
certificatesAndUserIds.add(new CertificateAndUserIds(parsedCert, userIds)); certificatesAndUserIds.add(new CertificateAndUserIds(parsedCert, userIds));
} }

View file

@ -11,7 +11,7 @@ import picocli.CommandLine;
@CommandLine.Command( @CommandLine.Command(
name = "wkd", name = "wkd",
description = "Interact with the Web Key Directory", resourceBundle = "msg_wkd",
subcommands = { subcommands = {
CommandLine.HelpCommand.class, CommandLine.HelpCommand.class,
GetCmd.class GetCmd.class

View file

@ -21,22 +21,18 @@ import java.io.OutputStream;
@CommandLine.Command( @CommandLine.Command(
name = "get", name = "get",
description = "Get an OpenPGP Certificate via the Web Key Directory" resourceBundle = "msg_get"
) )
public class GetCmd implements Runnable { public class GetCmd implements Runnable {
@CommandLine.Parameters( @CommandLine.Parameters(
index = "0", index = "0",
arity = "1", arity = "1",
paramLabel = "USERID", paramLabel = "USERID")
description = "Certificate User-ID"
)
String userId; String userId;
@CommandLine.Option( @CommandLine.Option(
names = {"-a", "--armor"}, names = {"-a", "--armor"})
description = "ASCII Armor the output"
)
boolean armor = false; boolean armor = false;
public static final CertificateDiscoverer DEFAULT_DISCOVERER = new ValidatingCertificateDiscoverer( public static final CertificateDiscoverer DEFAULT_DISCOVERER = new ValidatingCertificateDiscoverer(

View file

@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Get an OpenPGP Certificate via the Web Key Directory
USERID[0]=Certificate User-ID
armor=ASCII Armor the output
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Usage:\u0020
usage.commandListHeading = %nCommands:%n
usage.optionListHeading = %nOptions:%n
usage.footerHeading=Powered by picocli%n

View file

@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Empfange ein OpenPGP Zertifikat mithilfe des Web Key Directory
USERID[0]=Nutzeridentität des Zertifikats
armor=Schütze die Ausgabe mit ASCII Armor
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Aufruf:\u0020
usage.commandListHeading=%nBefehle:%n
usage.optionListHeading = %nOptionen:%n
usage.footerHeading=Powered by Picocli%n

View file

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Interact with the Web Key Directory
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Usage:\u0020
usage.commandListHeading = %nCommands:%n
usage.optionListHeading = %nOptions:%n
usage.footerHeading=Powered by picocli%n

View file

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Interagiere mit dem Web Key Directory
# Generic TODO: Remove when bumping picocli to 4.7.0
usage.synopsisHeading=Aufruf:\u0020
usage.commandListHeading=%nBefehle:%n
usage.optionListHeading = %nOptionen:%n
usage.footerHeading=Powered by Picocli%n

View file

@ -16,7 +16,7 @@ public class TestGetKeysFromGithubPages extends RedirectSystemStreamsTest {
// Valid WKD publication. // Valid WKD publication.
// Cert is available at https://pgpainless.github.io/.well-known/openpgpkey/hu/eprjcbeppbna3f6xabhtpddzpn41nknw // Cert is available at https://pgpainless.github.io/.well-known/openpgpkey/hu/eprjcbeppbna3f6xabhtpddzpn41nknw
private static final String USERID_BASE = "WKD Test <wkd-test-base@pgpainless.github.io> [Base Case - Valid User-ID]"; private static final String USERID_BASE = "WKD Test (Base Case - Valid User-ID) <wkd-test-base@pgpainless.github.io>";
private static final String MAIL_BASE = "wkd-test-base@pgpainless.github.io"; private static final String MAIL_BASE = "wkd-test-base@pgpainless.github.io";
@Test @Test

View file

@ -4,7 +4,7 @@
package pgp.wkd; package pgp.wkd;
import pgp.certificate_store.Certificate; import pgp.certificate_store.certificate.Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -4,7 +4,8 @@
package pgp.wkd; package pgp.wkd;
import pgp.certificate_store.Certificate;
import pgp.certificate_store.certificate.Certificate;
/** /**
* A rejected OpenPGP certificate. * A rejected OpenPGP certificate.

View file

@ -4,7 +4,7 @@
package pgp.wkd.discovery; package pgp.wkd.discovery;
import pgp.certificate_store.Certificate; import pgp.certificate_store.certificate.Certificate;
import pgp.wkd.RejectedCertificate; import pgp.wkd.RejectedCertificate;
import pgp.wkd.WKDAddress; import pgp.wkd.WKDAddress;
import pgp.wkd.exception.MissingPolicyFileException; import pgp.wkd.exception.MissingPolicyFileException;
@ -12,6 +12,7 @@ import pgp.wkd.exception.MissingPolicyFileException;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.net.URI; import java.net.URI;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -170,8 +171,8 @@ public final class DiscoveryResponse {
private DiscoveryMethod discoveryMethod; private DiscoveryMethod discoveryMethod;
private WKDAddress address; private WKDAddress address;
private List<Certificate> acceptableCertificates; private List<Certificate> acceptableCertificates = new ArrayList<>();
private List<RejectedCertificate> rejectedCertificates; private List<RejectedCertificate> rejectedCertificates = new ArrayList<>();
private Throwable fetchingFailure; private Throwable fetchingFailure;
private WKDPolicy policy; private WKDPolicy policy;
private MissingPolicyFileException missingPolicyFileException; private MissingPolicyFileException missingPolicyFileException;

View file

@ -4,7 +4,7 @@
package pgp.wkd.discovery; package pgp.wkd.discovery;
import pgp.certificate_store.Certificate; import pgp.certificate_store.certificate.Certificate;
import pgp.wkd.exception.CertNotFetchableException; import pgp.wkd.exception.CertNotFetchableException;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View file

@ -4,7 +4,7 @@
package pgp.wkd.discovery; package pgp.wkd.discovery;
import pgp.certificate_store.Certificate; import pgp.certificate_store.certificate.Certificate;
import pgp.wkd.CertificateAndUserIds; import pgp.wkd.CertificateAndUserIds;
import pgp.wkd.exception.MissingPolicyFileException; import pgp.wkd.exception.MissingPolicyFileException;
import pgp.wkd.exception.RejectedCertificateException; import pgp.wkd.exception.RejectedCertificateException;

View file

@ -38,7 +38,7 @@ public class AbstractTestSuiteGenerator {
} }
protected PGPSecretKeyRing secretKey(String userId) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException { protected PGPSecretKeyRing secretKey(String userId) throws PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException {
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing(userId, null); PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().modernKeyRing(userId);
return secretKeys; return secretKeys;
} }