2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package org.pgpainless.sop;
|
2020-12-16 20:09:01 +01:00
|
|
|
|
2021-03-05 13:04:28 +01:00
|
|
|
import java.io.IOException;
|
2021-10-04 16:28:56 +02:00
|
|
|
import java.io.InputStream;
|
2022-01-10 17:11:28 +01:00
|
|
|
import java.util.Locale;
|
2021-03-05 13:04:28 +01:00
|
|
|
import java.util.Properties;
|
|
|
|
|
2022-01-07 14:28:36 +01:00
|
|
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Version;
|
2021-03-05 13:04:28 +01:00
|
|
|
|
2023-01-16 19:38:52 +01:00
|
|
|
/**
|
|
|
|
* Implementation of the <pre>version</pre> operation using PGPainless.
|
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public class VersionImpl implements Version {
|
2022-01-09 01:24:56 +01:00
|
|
|
|
|
|
|
// draft version
|
2023-04-14 14:36:31 +02:00
|
|
|
private static final String SOP_VERSION = "06";
|
2022-01-09 01:24:56 +01:00
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "PGPainless-SOP";
|
|
|
|
}
|
2020-11-26 11:00:48 +01:00
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public String getVersion() {
|
2021-03-05 13:04:28 +01:00
|
|
|
// See https://stackoverflow.com/a/50119235
|
|
|
|
String version;
|
|
|
|
try {
|
|
|
|
Properties properties = new Properties();
|
2021-10-04 16:28:56 +02:00
|
|
|
InputStream propertiesFileIn = getClass().getResourceAsStream("/version.properties");
|
|
|
|
if (propertiesFileIn == null) {
|
|
|
|
throw new IOException("File version.properties not found.");
|
|
|
|
}
|
|
|
|
properties.load(propertiesFileIn);
|
2021-03-05 13:04:28 +01:00
|
|
|
version = properties.getProperty("version");
|
|
|
|
} catch (IOException e) {
|
|
|
|
version = "DEVELOPMENT";
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
return version;
|
2020-11-26 11:00:48 +01:00
|
|
|
}
|
2022-01-07 14:28:36 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getBackendVersion() {
|
|
|
|
double bcVersion = new BouncyCastleProvider().getVersion();
|
2022-01-10 17:11:28 +01:00
|
|
|
return String.format(Locale.US, "Bouncy Castle %.2f", bcVersion);
|
2022-01-07 14:28:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getExtendedVersion() {
|
|
|
|
return getName() + " " + getVersion() + "\n" +
|
2022-01-10 17:11:28 +01:00
|
|
|
"https://codeberg.org/PGPainless/pgpainless/src/branch/master/pgpainless-sop\n" +
|
|
|
|
"\n" +
|
2022-01-09 01:24:56 +01:00
|
|
|
"Implementation of the Stateless OpenPGP Protocol Version " + SOP_VERSION + "\n" +
|
2022-01-10 17:11:28 +01:00
|
|
|
"https://datatracker.ietf.org/doc/html/draft-dkg-openpgp-stateless-cli-" + SOP_VERSION + "\n" +
|
|
|
|
"\n" +
|
|
|
|
"Based on pgpainless-core " + getVersion() + "\n" +
|
|
|
|
"https://pgpainless.org\n" +
|
|
|
|
"\n" +
|
|
|
|
"Using " + getBackendVersion() + "\n" +
|
|
|
|
"https://www.bouncycastle.org/java.html";
|
2022-01-07 14:28:36 +01:00
|
|
|
}
|
2020-11-26 11:00:48 +01:00
|
|
|
}
|