mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-25 16:42:07 +01:00
Kotlin conversion: InlineVerify
This commit is contained in:
parent
be0ceb0886
commit
6c14f249bb
2 changed files with 42 additions and 54 deletions
|
@ -1,54 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package sop.operation;
|
|
||||||
|
|
||||||
import sop.ReadyWithResult;
|
|
||||||
import sop.Verification;
|
|
||||||
import sop.exception.SOPGPException;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API for verification of inline-signed messages.
|
|
||||||
*/
|
|
||||||
public interface InlineVerify extends AbstractVerify<InlineVerify> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the inline-signed data.
|
|
||||||
* The result can be used to write the plaintext message out and to get the verifications.
|
|
||||||
*
|
|
||||||
* @param data signed data
|
|
||||||
* @return list of signature verifications
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws SOPGPException.NoSignature when no signature is found
|
|
||||||
* @throws SOPGPException.BadData when the data is invalid OpenPGP data
|
|
||||||
*/
|
|
||||||
ReadyWithResult<List<Verification>> data(InputStream data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.NoSignature,
|
|
||||||
SOPGPException.BadData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the inline-signed data.
|
|
||||||
* The result can be used to write the plaintext message out and to get the verifications.
|
|
||||||
*
|
|
||||||
* @param data signed data
|
|
||||||
* @return list of signature verifications
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws SOPGPException.NoSignature when no signature is found
|
|
||||||
* @throws SOPGPException.BadData when the data is invalid OpenPGP data
|
|
||||||
*/
|
|
||||||
default ReadyWithResult<List<Verification>> data(byte[] data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.NoSignature,
|
|
||||||
SOPGPException.BadData {
|
|
||||||
return data(new ByteArrayInputStream(data));
|
|
||||||
}
|
|
||||||
}
|
|
42
sop-java/src/main/kotlin/sop/operation/InlineVerify.kt
Normal file
42
sop-java/src/main/kotlin/sop/operation/InlineVerify.kt
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package sop.operation
|
||||||
|
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InputStream
|
||||||
|
import sop.ReadyWithResult
|
||||||
|
import sop.Verification
|
||||||
|
import sop.exception.SOPGPException.BadData
|
||||||
|
import sop.exception.SOPGPException.NoSignature
|
||||||
|
|
||||||
|
/** API for verification of inline-signed messages. */
|
||||||
|
interface InlineVerify : AbstractVerify<InlineVerify> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide the inline-signed data. The result can be used to write the plaintext message out and
|
||||||
|
* to get the verifications.
|
||||||
|
*
|
||||||
|
* @param data signed data
|
||||||
|
* @return list of signature verifications
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws NoSignature when no signature is found
|
||||||
|
* @throws BadData when the data is invalid OpenPGP data
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, NoSignature::class, BadData::class)
|
||||||
|
fun data(data: InputStream): ReadyWithResult<List<Verification>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide the inline-signed data. The result can be used to write the plaintext message out and
|
||||||
|
* to get the verifications.
|
||||||
|
*
|
||||||
|
* @param data signed data
|
||||||
|
* @return list of signature verifications
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws NoSignature when no signature is found
|
||||||
|
* @throws BadData when the data is invalid OpenPGP data
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, NoSignature::class, BadData::class)
|
||||||
|
fun data(data: ByteArray): ReadyWithResult<List<Verification>> = data(data.inputStream())
|
||||||
|
}
|
Loading…
Reference in a new issue