pgpainless/pgpainless-sop/src/main/java/org/pgpainless/sop/SOPImpl.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

150 lines
3.0 KiB
Java
Raw Normal View History

2021-10-07 15:48:52 +02:00
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.pgpainless.sop;
import org.pgpainless.util.ArmoredOutputStreamFactory;
import sop.SOP;
import sop.SOPV;
import sop.operation.Armor;
import sop.operation.ChangeKeyPassword;
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;
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;
import sop.operation.RevokeKey;
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
*/
public class SOPImpl implements SOP {
static {
ArmoredOutputStreamFactory.setVersionInfo(null);
}
2024-03-24 11:00:16 +01:00
// Delegate for sig verification operations
private final SOPV sopv = new SOPVImpl();
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public Version version() {
2024-03-24 11:00:16 +01:00
// Delegate to SOPV
return sopv.version();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public GenerateKey generateKey() {
return new GenerateKeyImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
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();
}
@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
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
return sopv.inlineVerify();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public Encrypt encrypt() {
return new EncryptImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public Decrypt decrypt() {
return new DecryptImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public Armor armor() {
return new ArmorImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public Dearmor dearmor() {
return new DearmorImpl();
}
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();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public RevokeKey revokeKey() {
return new RevokeKeyImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
public ChangeKeyPassword changeKeyPassword() {
return new ChangeKeyPasswordImpl();
}
@Override
2023-11-15 13:39:26 +01:00
@Nonnull
2022-06-07 08:55:10 +02:00
public InlineDetach inlineDetach() {
return new InlineDetachImpl();
}
}