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;
|
|
|
|
|
2022-11-11 13:45:25 +01:00
|
|
|
import org.pgpainless.util.ArmoredOutputStreamFactory;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.SOP;
|
2024-03-17 15:54:44 +01:00
|
|
|
import sop.SOPV;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Armor;
|
2023-07-12 00:40:59 +02:00
|
|
|
import sop.operation.ChangeKeyPassword;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Dearmor;
|
|
|
|
import sop.operation.Decrypt;
|
2022-06-07 08:55:10 +02:00
|
|
|
import sop.operation.DetachedSign;
|
|
|
|
import sop.operation.DetachedVerify;
|
|
|
|
import sop.operation.InlineDetach;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Encrypt;
|
|
|
|
import sop.operation.ExtractCert;
|
|
|
|
import sop.operation.GenerateKey;
|
2022-06-07 08:55:10 +02:00
|
|
|
import sop.operation.InlineSign;
|
|
|
|
import sop.operation.InlineVerify;
|
2023-04-14 14:31:48 +02:00
|
|
|
import sop.operation.ListProfiles;
|
2023-07-11 23:15:22 +02:00
|
|
|
import sop.operation.RevokeKey;
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Version;
|
|
|
|
|
2023-11-15 13:39:26 +01:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2023-01-16 19:38:52 +01:00
|
|
|
/**
|
|
|
|
* Implementation of the <pre>sop</pre> API using PGPainless.
|
|
|
|
* <pre> {@code
|
|
|
|
* SOP sop = new SOPImpl();
|
|
|
|
* }</pre>
|
2024-03-24 11:00:16 +01:00
|
|
|
*
|
|
|
|
* For a slimmed down interface that merely focuses on signature verification, see {@link SOPVImpl}.
|
2023-01-16 19:38:52 +01:00
|
|
|
*/
|
2021-07-15 16:55:13 +02:00
|
|
|
public class SOPImpl implements SOP {
|
|
|
|
|
2022-11-11 13:45:25 +01:00
|
|
|
static {
|
|
|
|
ArmoredOutputStreamFactory.setVersionInfo(null);
|
|
|
|
}
|
|
|
|
|
2024-03-24 11:00:16 +01:00
|
|
|
// Delegate for sig verification operations
|
2024-03-17 15:54:44 +01:00
|
|
|
private final SOPV sopv = new SOPVImpl();
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public Version version() {
|
2024-03-24 11:00:16 +01:00
|
|
|
// Delegate to SOPV
|
2024-03-17 15:54:44 +01:00
|
|
|
return sopv.version();
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public GenerateKey generateKey() {
|
|
|
|
return new GenerateKeyImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public ExtractCert extractCert() {
|
|
|
|
return new ExtractCertImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public DetachedSign sign() {
|
|
|
|
return detachedSign();
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public DetachedSign detachedSign() {
|
|
|
|
return new DetachedSignImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public InlineSign inlineSign() {
|
|
|
|
return new InlineSignImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public DetachedVerify verify() {
|
|
|
|
return detachedVerify();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public DetachedVerify detachedVerify() {
|
2024-03-24 11:00:16 +01:00
|
|
|
// Delegate to SOPV
|
2024-03-17 15:54:44 +01:00
|
|
|
return sopv.detachedVerify();
|
2022-06-07 08:55:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public InlineVerify inlineVerify() {
|
2024-03-24 11:00:16 +01:00
|
|
|
// Delegate to SOPV
|
2024-03-17 15:54:44 +01:00
|
|
|
return sopv.inlineVerify();
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public Encrypt encrypt() {
|
|
|
|
return new EncryptImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public Decrypt decrypt() {
|
|
|
|
return new DecryptImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public Armor armor() {
|
|
|
|
return new ArmorImpl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2021-07-15 16:55:13 +02:00
|
|
|
public Dearmor dearmor() {
|
|
|
|
return new DearmorImpl();
|
|
|
|
}
|
2021-08-18 18:27:22 +02:00
|
|
|
|
2023-04-14 14:31:48 +02:00
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2023-04-14 14:31:48 +02:00
|
|
|
public ListProfiles listProfiles() {
|
|
|
|
return new ListProfilesImpl();
|
|
|
|
}
|
|
|
|
|
2023-07-11 23:15:22 +02:00
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2023-07-11 23:15:22 +02:00
|
|
|
public RevokeKey revokeKey() {
|
|
|
|
return new RevokeKeyImpl();
|
|
|
|
}
|
|
|
|
|
2023-07-12 00:40:59 +02:00
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2023-07-12 00:40:59 +02:00
|
|
|
public ChangeKeyPassword changeKeyPassword() {
|
|
|
|
return new ChangeKeyPasswordImpl();
|
|
|
|
}
|
|
|
|
|
2021-08-18 18:27:22 +02:00
|
|
|
@Override
|
2023-11-15 13:39:26 +01:00
|
|
|
@Nonnull
|
2022-06-07 08:55:10 +02:00
|
|
|
public InlineDetach inlineDetach() {
|
|
|
|
return new InlineDetachImpl();
|
2021-08-18 18:27:22 +02:00
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
}
|