mirror of
https://codeberg.org/PGPainless/vks-java.git
synced 2024-09-27 18:49:32 +02:00
Compare commits
No commits in common. "main" and "0.1.2" have entirely different histories.
|
@ -13,8 +13,3 @@ 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
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
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]
|
|
@ -1,7 +0,0 @@
|
|||
# Code is licensed properly
|
||||
# See https://reuse.software/
|
||||
pipeline:
|
||||
reuse:
|
||||
image: fsfe/reuse:latest
|
||||
commands:
|
||||
- reuse lint
|
|
@ -6,11 +6,6 @@ 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`
|
||||
|
@ -24,4 +19,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
|
|
@ -6,10 +6,6 @@ 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.
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
allprojects {
|
||||
ext {
|
||||
shortVersion = '0.1.4'
|
||||
isSnapshot = true
|
||||
shortVersion = '0.1.2'
|
||||
isSnapshot = false
|
||||
minAndroidSdk = 10
|
||||
javaSourceCompatibility = 1.8
|
||||
bouncycastleVersion = '1.75'
|
||||
bouncycastleVersion = '1.71'
|
||||
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.15.2'
|
||||
jacksonDataBindVersion = '2.13.2.2'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,8 @@ 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",
|
||||
resourceBundle = "msg_get")
|
||||
@CommandLine.Command(name = "get", description = "Retrieve an OpenPGP certificate from the key server")
|
||||
public class GetCmd implements Runnable {
|
||||
|
||||
@CommandLine.Mixin
|
||||
|
@ -26,22 +22,16 @@ public class GetCmd implements Runnable {
|
|||
Exclusive by;
|
||||
|
||||
static class Exclusive {
|
||||
@CommandLine.Option(names = {"-f", "--by-fingerprint"})
|
||||
@CommandLine.Option(names = {"-f", "--by-fingerprint"}, description = "Retrieve a key by its fingerprint (NOT prefixed with '0x')")
|
||||
String fingerprint;
|
||||
|
||||
@CommandLine.Option(names = {"-i", "--by-keyid"})
|
||||
@CommandLine.Option(names = {"-i", "--by-keyid"}, description = "Retrieve a key by its decimal key ID or that of one of its subkeys.")
|
||||
Long keyId;
|
||||
|
||||
@CommandLine.Option(names = {"-e", "--by-email"})
|
||||
@CommandLine.Option(names = {"-e", "--by-email"}, description = "Retrieve a key by email address.")
|
||||
String email;
|
||||
}
|
||||
|
||||
private final ResourceBundle msg;
|
||||
|
||||
public GetCmd() {
|
||||
msg = ResourceBundle.getBundle("msg_get", Locale.getDefault());
|
||||
}
|
||||
|
||||
public void run() {
|
||||
VKS vks;
|
||||
try {
|
||||
|
@ -60,7 +50,7 @@ public class GetCmd implements Runnable {
|
|||
} else if (by.email != null) {
|
||||
inputStream = get.byEmail(by.email);
|
||||
} else {
|
||||
throw new IllegalArgumentException(msg.getString("error.missing_by_option"));
|
||||
throw new IllegalArgumentException("Missing --by-* option.");
|
||||
}
|
||||
|
||||
int read;
|
||||
|
|
|
@ -12,32 +12,23 @@ 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",
|
||||
resourceBundle = "msg_request_verification")
|
||||
@CommandLine.Command(name = "request-verification", description = "Request verification for unverified user-ids")
|
||||
public class RequestVerificationCmd implements Runnable {
|
||||
|
||||
@CommandLine.Mixin
|
||||
VKSCLI.KeyServerMixin keyServerMixin;
|
||||
|
||||
@CommandLine.Option(names = {"-t", "--token"},
|
||||
@CommandLine.Option(names = {"-t", "--token"}, description = "Access token. Can be retrieved by uploading the certificate.",
|
||||
required = true, arity = "1", paramLabel = "TOKEN")
|
||||
String token;
|
||||
|
||||
@CommandLine.Option(names = {"-l", "--locale"})
|
||||
@CommandLine.Option(names = {"-l", "--locale"}, description = "Locale for the verification mail")
|
||||
List<String> locale = Arrays.asList("en_US", "en_GB");
|
||||
|
||||
@CommandLine.Option(names = {"-e", "--email"}, required = true, arity = "1..*")
|
||||
@CommandLine.Option(names = {"-e", "--email"}, description = "Email addresses to request a verification mail for", 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() {
|
||||
|
@ -53,9 +44,10 @@ public class RequestVerificationCmd implements Runnable {
|
|||
RequestVerify.Response response = requestVerify
|
||||
.forEmailAddresses(addresses)
|
||||
.execute(token, locale);
|
||||
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"));
|
||||
|
||||
System.out.println("Verification E-Mails for key " + response.getKeyFingerprint() + " have been sent.");
|
||||
System.out.println("Token: " + response.getToken());
|
||||
System.out.println("Status:");
|
||||
for (String address : response.getStatus().keySet()) {
|
||||
System.out.println("\t" + address + "\t" + response.getStatus().get(address));
|
||||
}
|
||||
|
|
|
@ -15,26 +15,17 @@ 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",
|
||||
resourceBundle = "msg_upload")
|
||||
@CommandLine.Command(name = "upload", description = "Upload an OpenPGP certificate to the key server")
|
||||
public class UploadCmd implements Runnable {
|
||||
|
||||
@CommandLine.Mixin
|
||||
VKSCLI.KeyServerMixin keyServerMixin;
|
||||
|
||||
@CommandLine.Option(names = {"-r", "--request-verification"})
|
||||
@CommandLine.Option(names = {"-r", "--request-verification"},
|
||||
description = "Request verification mails for unpublished email addresses")
|
||||
boolean requestVerification;
|
||||
|
||||
private final ResourceBundle msg;
|
||||
|
||||
public UploadCmd() {
|
||||
msg = ResourceBundle.getBundle("msg_upload", Locale.getDefault());
|
||||
}
|
||||
|
||||
public void run() {
|
||||
VKS vks;
|
||||
try {
|
||||
|
@ -60,13 +51,11 @@ public class UploadCmd implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
String msgUpload = String.format(msg.getString("output.uploaded_key"),
|
||||
response.getKeyFingerprint(), response.getToken());
|
||||
System.out.println(msgUpload);
|
||||
System.out.println("Uploaded key " + response.getKeyFingerprint());
|
||||
System.out.println("Token: " + response.getToken());
|
||||
|
||||
String msgStatus = msg.getString("output.status");
|
||||
if (!requestVerification || unpublished.isEmpty()) {
|
||||
System.out.println(msgStatus);
|
||||
System.out.println("Status:");
|
||||
for (String address : response.getStatus().keySet()) {
|
||||
Status status = response.getStatus().get(address);
|
||||
System.out.format("%-" + maxMailLen + "s %s\n", address, status);
|
||||
|
@ -76,7 +65,7 @@ public class UploadCmd implements Runnable {
|
|||
|
||||
RequestVerify.Response verifyResponse = vks.requestVerification().forEmailAddresses(unpublished.toArray(new String[0]))
|
||||
.execute(response.getToken());
|
||||
System.out.println(msgStatus);
|
||||
System.out.println("Status:");
|
||||
for (String address : verifyResponse.getStatus().keySet()) {
|
||||
Status status = response.getStatus().get(address);
|
||||
System.out.format("%-" + maxMailLen + "s %s\n", address, status);
|
||||
|
|
|
@ -9,12 +9,10 @@ import pgp.vks.client.VKSImpl;
|
|||
import picocli.CommandLine;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "vks",
|
||||
resourceBundle = "msg_vks",
|
||||
description = "Interact with Verifying Key Servers",
|
||||
subcommands = {
|
||||
CommandLine.HelpCommand.class,
|
||||
GetCmd.class,
|
||||
|
@ -34,15 +32,14 @@ public class VKSCLI {
|
|||
}
|
||||
|
||||
public static int execute(String[] args) {
|
||||
CommandLine cmd = new CommandLine(VKSCLI.class);
|
||||
cmd.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() {
|
||||
return new CommandLine(VKSCLI.class)
|
||||
.setExitCodeExceptionMapper(new CommandLine.IExitCodeExceptionMapper() {
|
||||
@Override
|
||||
public int getExitCode(Throwable exception) {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
cmd.getSubcommands().get("help").setResourceBundle(ResourceBundle.getBundle("msg_help", Locale.getDefault()));
|
||||
return cmd.setCommandName("vkscli")
|
||||
})
|
||||
.setCommandName("vkscli")
|
||||
.execute(args);
|
||||
}
|
||||
|
||||
|
@ -56,6 +53,7 @@ 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;
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# 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'
|
|
@ -1,12 +0,0 @@
|
|||
# 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'
|
|
@ -1,5 +0,0 @@
|
|||
# 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
|
|
@ -1,6 +0,0 @@
|
|||
# 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
|
|
@ -1,11 +0,0 @@
|
|||
# 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'
|
|
@ -1,14 +0,0 @@
|
|||
# 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'
|
|
@ -1,8 +0,0 @@
|
|||
# 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'
|
|
@ -1,11 +0,0 @@
|
|||
# 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'
|
|
@ -1,6 +0,0 @@
|
|||
# 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
|
|
@ -1,6 +0,0 @@
|
|||
# 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
|
Loading…
Reference in a new issue