Compare commits

...

10 Commits

Author SHA1 Message Date
Paul Schaub 57434d80cf
VKS-Java 0.1.4-SNAPSHOT 2023-07-07 12:48:59 +02:00
Paul Schaub 32a2909c53
VKS-Java 0.1.3 2023-07-07 12:47:27 +02:00
Paul Schaub 23cc79aaa8
Update changelog 2023-07-07 12:45:48 +02:00
Paul Schaub 3f68ae5725
Bump bcpg to 1.75 2023-07-07 12:44:00 +02:00
Paul Schaub 09f45e86db
Bump jackson-databind to 2.15.2 2023-07-07 12:43:21 +02:00
Paul Schaub ec59e717fc
Update changelog 2022-11-25 15:54:46 +01:00
Paul Schaub 1d65b4b3c2
Bump bc-util to 1.72 2022-11-25 15:54:05 +01:00
Paul Schaub e37921b4d4
Add support for i18n using resource bundles 2022-08-04 00:49:08 +02:00
Paul Schaub f349c701fa
Add badges for CI and Coveralls 2022-08-01 17:28:44 +02:00
Paul Schaub 867eebe684
Add woodpecker CI 2022-08-01 17:25:21 +02:00
20 changed files with 182 additions and 30 deletions

View File

@ -13,3 +13,8 @@ Source: https://pgpainless.org
Files: gradle*
Copyright: 2015 the original author or authors.
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,6 +6,11 @@ SPDX-License-Identifier: Apache-2.0
# Changelog
## 0.1.3
- Bump `bc-util` to `1.75`
- Bump `jackson-databind` to `2.15.2`
- Add support for resource bundles for i18n
## 0.1.2
- Bump `slf4j` to `1.7.36`
- Bump `logback` to `1.2.11`
@ -19,4 +24,4 @@ SPDX-License-Identifier: Apache-2.0
## 0.1.0
- Initial release
- `vks-java`: Client side API to communicate with Verifying Key Servers
- `vks-java`: Client side API to communicate with Verifying Key Servers

View File

@ -6,6 +6,10 @@ SPDX-License-Identifier: Apache-2.0
# Verifying Key Server - Client API for Java
[![status-badge](https://ci.codeberg.org/api/badges/PGPainless/vks-java/status.svg)](https://ci.codeberg.org/PGPainless/vks-java)
[![Coverage Status](https://coveralls.io/repos/github/pgpainless/vks-java/badge.svg?branch=main)](https://coveralls.io/github/pgpainless/vks-java?branch=main)
[![REUSE status](https://api.reuse.software/badge/github.com/pgpainless/vks-java)](https://api.reuse.software/info/github.com/pgpainless/vks-java)
Client-side API for fetching keys from - and publishing keys to - Verifying OpenPGP Key Servers (VKS).
An example implementation of a Verifying Key Server is [Hagrid](https://gitlab.com/hagrid-keyserver/hagrid), which is running https://keys.openpgp.org.

View File

@ -4,17 +4,17 @@
allprojects {
ext {
shortVersion = '0.1.3'
shortVersion = '0.1.4'
isSnapshot = true
minAndroidSdk = 10
javaSourceCompatibility = 1.8
bouncycastleVersion = '1.71'
bouncycastleVersion = '1.75'
junitVersion = '5.8.2'
jsrVersion = '3.0.2'
slf4jVersion = '1.7.36'
logbackVersion = '1.2.11'
lombokVersion = '1.18.24'
picocliVersion = '4.6.3'
jacksonDataBindVersion = '2.13.2.2'
jacksonDataBindVersion = '2.15.2'
}
}

View File

@ -11,8 +11,12 @@ import picocli.CommandLine;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Locale;
import java.util.ResourceBundle;
@CommandLine.Command(name = "get", description = "Retrieve an OpenPGP certificate from the key server")
@CommandLine.Command(
name = "get",
resourceBundle = "msg_get")
public class GetCmd implements Runnable {
@CommandLine.Mixin
@ -22,16 +26,22 @@ public class GetCmd implements Runnable {
Exclusive by;
static class Exclusive {
@CommandLine.Option(names = {"-f", "--by-fingerprint"}, description = "Retrieve a key by its fingerprint (NOT prefixed with '0x')")
@CommandLine.Option(names = {"-f", "--by-fingerprint"})
String fingerprint;
@CommandLine.Option(names = {"-i", "--by-keyid"}, description = "Retrieve a key by its decimal key ID or that of one of its subkeys.")
@CommandLine.Option(names = {"-i", "--by-keyid"})
Long keyId;
@CommandLine.Option(names = {"-e", "--by-email"}, description = "Retrieve a key by email address.")
@CommandLine.Option(names = {"-e", "--by-email"})
String email;
}
private final ResourceBundle msg;
public GetCmd() {
msg = ResourceBundle.getBundle("msg_get", Locale.getDefault());
}
public void run() {
VKS vks;
try {
@ -50,7 +60,7 @@ public class GetCmd implements Runnable {
} else if (by.email != null) {
inputStream = get.byEmail(by.email);
} else {
throw new IllegalArgumentException("Missing --by-* option.");
throw new IllegalArgumentException(msg.getString("error.missing_by_option"));
}
int read;

View File

@ -12,23 +12,32 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@CommandLine.Command(name = "request-verification", description = "Request verification for unverified user-ids")
@CommandLine.Command(
name = "request-verification",
resourceBundle = "msg_request_verification")
public class RequestVerificationCmd implements Runnable {
@CommandLine.Mixin
VKSCLI.KeyServerMixin keyServerMixin;
@CommandLine.Option(names = {"-t", "--token"}, description = "Access token. Can be retrieved by uploading the certificate.",
@CommandLine.Option(names = {"-t", "--token"},
required = true, arity = "1", paramLabel = "TOKEN")
String token;
@CommandLine.Option(names = {"-l", "--locale"}, description = "Locale for the verification mail")
@CommandLine.Option(names = {"-l", "--locale"})
List<String> locale = Arrays.asList("en_US", "en_GB");
@CommandLine.Option(names = {"-e", "--email"}, description = "Email addresses to request a verification mail for", required = true, arity = "1..*")
@CommandLine.Option(names = {"-e", "--email"}, required = true, arity = "1..*")
String[] addresses = new String[0];
private final ResourceBundle msg;
public RequestVerificationCmd() {
msg = ResourceBundle.getBundle("msg_request_verification", Locale.getDefault());
}
@Override
public void run() {
@ -44,10 +53,9 @@ public class RequestVerificationCmd implements Runnable {
RequestVerify.Response response = requestVerify
.forEmailAddresses(addresses)
.execute(token, locale);
System.out.println("Verification E-Mails for key " + response.getKeyFingerprint() + " have been sent.");
System.out.println("Token: " + response.getToken());
System.out.println("Status:");
System.out.printf(msg.getString("output.mails_sent"), response.getKeyFingerprint());
System.out.printf(msg.getString("output.token"), response.getToken());
System.out.println(msg.getString("output.status"));
for (String address : response.getStatus().keySet()) {
System.out.println("\t" + address + "\t" + response.getStatus().get(address));
}

View File

@ -15,17 +15,26 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@CommandLine.Command(name = "upload", description = "Upload an OpenPGP certificate to the key server")
@CommandLine.Command(
name = "upload",
resourceBundle = "msg_upload")
public class UploadCmd implements Runnable {
@CommandLine.Mixin
VKSCLI.KeyServerMixin keyServerMixin;
@CommandLine.Option(names = {"-r", "--request-verification"},
description = "Request verification mails for unpublished email addresses")
@CommandLine.Option(names = {"-r", "--request-verification"})
boolean requestVerification;
private final ResourceBundle msg;
public UploadCmd() {
msg = ResourceBundle.getBundle("msg_upload", Locale.getDefault());
}
public void run() {
VKS vks;
try {
@ -51,11 +60,13 @@ public class UploadCmd implements Runnable {
}
}
System.out.println("Uploaded key " + response.getKeyFingerprint());
System.out.println("Token: " + response.getToken());
String msgUpload = String.format(msg.getString("output.uploaded_key"),
response.getKeyFingerprint(), response.getToken());
System.out.println(msgUpload);
String msgStatus = msg.getString("output.status");
if (!requestVerification || unpublished.isEmpty()) {
System.out.println("Status:");
System.out.println(msgStatus);
for (String address : response.getStatus().keySet()) {
Status status = response.getStatus().get(address);
System.out.format("%-" + maxMailLen + "s %s\n", address, status);
@ -65,7 +76,7 @@ public class UploadCmd implements Runnable {
RequestVerify.Response verifyResponse = vks.requestVerification().forEmailAddresses(unpublished.toArray(new String[0]))
.execute(response.getToken());
System.out.println("Status:");
System.out.println(msgStatus);
for (String address : verifyResponse.getStatus().keySet()) {
Status status = response.getStatus().get(address);
System.out.format("%-" + maxMailLen + "s %s\n", address, status);

View File

@ -9,10 +9,12 @@ import pgp.vks.client.VKSImpl;
import picocli.CommandLine;
import java.net.MalformedURLException;
import java.util.Locale;
import java.util.ResourceBundle;
@CommandLine.Command(
name = "vks",
description = "Interact with Verifying Key Servers",
resourceBundle = "msg_vks",
subcommands = {
CommandLine.HelpCommand.class,
GetCmd.class,
@ -32,14 +34,15 @@ public class VKSCLI {
}
public static int execute(String[] args) {
return new CommandLine(VKSCLI.class)
.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() {
CommandLine cmd = new CommandLine(VKSCLI.class);
cmd.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() {
@Override
public int getExitCode(Throwable exception) {
return 1;
}
})
.setCommandName("vkscli")
});
cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("msg_help", Locale.getDefault()));
return cmd.setCommandName("vkscli")
.execute(args);
}
@ -53,7 +56,6 @@ public class VKSCLI {
VKSCLI parent;
@CommandLine.Option(names = "--key-server",
description = "Address of the Verifying Key Server.\nDefaults to 'https://keys.openpgp.org'",
paramLabel = "KEYSERVER")
public void setKeyServer(String keyServer) {
parent.keyServer = keyServer;

View File

@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Retrieve an OpenPGP certificate from the key server
by-fingerprint=Retrieve a key by its fingerprint (NOT prefixed with '0x')
by-keyid=Retrieve a key by its decimal key ID or that of one of its subkeys
by-email=Retrieve a key by email address
error.missing_by_option=Missing --by-* option.
key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org'

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 vom Schlüsselserver
by-fingerprint=Finde das Zertifikat anhand seines Fingerabdrucks (OHNE Präfix '0x')
by-keyid=Finde das Zertifikat anhand seiner Schlüssel-ID oder der eines seiner Unterschlüssel
by-email=Finde das Zertifikat anhand einer E-Mail-Adresse
error.missing_by_option=Fehlende --by-* Option.
usage.synopsisHeading=Nutzung:\u0020
usage.optionListHeading=Optionen:%n
key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org'

View File

@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Displays help information about the specified command
usage.synopsisHeading=Usage:\u0020

View File

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Zeige Hilfetext für den angegebenen Befehl
usage.synopsisHeading=Nutzung:\u0020
usage.optionListHeading=Optionen:%n

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Request verification for unverified user-ids
token=Access token. Can be retrieved by uploading the certificate.
locale=Locale (language) for the verification mail
email=Email addresses to request a verification mail for
output.mails_sent=Verification E-Mails for certificate %s have been sent.%n
output.token=Token: %s%n
output.status=Status:
key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org'

View File

@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Fordere Verifikation von unveröffentlichten Nutzeridentitäten an
token=Zugangstoken. Kann durch das Hochladen des Zertifikates erhalten werden.
locale=Gebietsschema (Sprache) für die E-Mail-Verifikation
email=E-Mail-Adresse für die eine Verifikation angefragt werden soll
output.mails_sent=E-Mail-Verifikationen für Zertifikat %s wurden versendet.%n%n
output.token=Zugangstoken: %s%n
output.status=Status:
usage.synopsisHeading=Nutzung:\u0020
usage.optionListHeading=Optionen:%n
key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org'

View File

@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Upload an OpenPGP certificate to the key server
request-verification=Request verification mails for unpublished email addresses
output.uploaded_key=Uploaded key: %s%nToken: %s
output.status=Status:
key-server=Address of the Verifying Key Server.%nDefaults to 'https://keys.openpgp.org'

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Lade ein OpenPGP Zertifikat auf den Schlüsselserver hoch
request-verification=Fordere E-Mailverifikation für unveröffentlichte E-Mail-Adressen an
output.uploaded_key=Hochgeladenes Zertifikat: %s%nToken: %s
output.status=Status:
usage.synopsisHeading=Nutzung:\u0020
usage.optionListHeading=Optionen:%n
key-server=Adresse des verifizierenden Schlüsselservers.%nStandardmäßig: 'https://keys.openpgp.org'

View File

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Interact with Verifying Key Servers
usage.synopsisHeading=Usage:\u0020
usage.commandListHeading=Commands:%n

View File

@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
#
# SPDX-License-Identifier: Apache-2.0
usage.header=Interagiere mit verifizierenden Schlüsselservern
usage.synopsisHeading=Nutzung:\u0020
usage.commandListHeading=Befehle:%n