Add handy shortcut methods to the API

This commit is contained in:
Paul Schaub 2020-08-24 16:57:14 +02:00
parent f10d698a09
commit 7de04c2949
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
1 changed files with 34 additions and 0 deletions

View File

@ -16,6 +16,7 @@
package org.pgpainless.decryption_verification;
import javax.annotation.Nonnull;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
@ -72,6 +73,39 @@ public interface DecryptionBuilderInterface {
interface Verify extends VerifyWith {
@Override
HandleMissingPublicKeys verifyWith(@Nonnull PGPPublicKeyRingCollection publicKeyRings);
@Override
default HandleMissingPublicKeys verifyWith(@Nonnull OpenPgpV4Fingerprint trustedFingerprint,
@Nonnull PGPPublicKeyRingCollection publicKeyRings) {
return verifyWith(Collections.singleton(trustedFingerprint), publicKeyRings);
}
@Override
HandleMissingPublicKeys verifyWith(@Nonnull Set<OpenPgpV4Fingerprint> trustedFingerprints,
@Nonnull PGPPublicKeyRingCollection publicKeyRings);
@Override
default HandleMissingPublicKeys verifyWith(@Nonnull PGPPublicKeyRing publicKeyRing) {
return verifyWith(Collections.singleton(publicKeyRing));
}
@Override
HandleMissingPublicKeys verifyWith(@Nonnull Set<PGPPublicKeyRing> publicKeyRings);
/**
* Pass in one or more detached signatures to verify.
*
* @param bytes detached signatures (ascii armored or binary).
* @return api handle
* @throws IOException if some IO error occurs
* @throws PGPException if the detached signatures are malformed
*/
default VerifyWith verifyDetachedSignature(@Nonnull byte[] bytes) throws IOException, PGPException {
return verifyDetachedSignature(new ByteArrayInputStream(bytes));
}
/**
* Pass in one or more detached signatures to verify.
*