mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-29 10:32:08 +01:00
Kotlin conversion: VerifySignatures
This commit is contained in:
parent
0ee4638beb
commit
a8c2e72ef5
2 changed files with 38 additions and 46 deletions
|
@ -1,46 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package sop.operation;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import sop.Verification;
|
|
||||||
import sop.exception.SOPGPException;
|
|
||||||
|
|
||||||
public interface VerifySignatures {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the signed data (without signatures).
|
|
||||||
*
|
|
||||||
* @param data signed data
|
|
||||||
* @return list of signature verifications
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws SOPGPException.NoSignature when no valid signature is found
|
|
||||||
* @throws SOPGPException.BadData when the data is invalid OpenPGP data
|
|
||||||
*/
|
|
||||||
List<Verification> data(InputStream data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.NoSignature,
|
|
||||||
SOPGPException.BadData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide the signed data (without signatures).
|
|
||||||
*
|
|
||||||
* @param data signed data
|
|
||||||
* @return list of signature verifications
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws SOPGPException.NoSignature when no valid signature is found
|
|
||||||
* @throws SOPGPException.BadData when the data is invalid OpenPGP data
|
|
||||||
*/
|
|
||||||
default List<Verification> data(byte[] data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.NoSignature,
|
|
||||||
SOPGPException.BadData {
|
|
||||||
return data(new ByteArrayInputStream(data));
|
|
||||||
}
|
|
||||||
}
|
|
38
sop-java/src/main/kotlin/sop/operation/VerifySignatures.kt
Normal file
38
sop-java/src/main/kotlin/sop/operation/VerifySignatures.kt
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// 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.Verification
|
||||||
|
import sop.exception.SOPGPException.BadData
|
||||||
|
import sop.exception.SOPGPException.NoSignature
|
||||||
|
|
||||||
|
interface VerifySignatures {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide the signed data (without signatures).
|
||||||
|
*
|
||||||
|
* @param data signed data
|
||||||
|
* @return list of signature verifications
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws NoSignature when no valid signature is found
|
||||||
|
* @throws BadData when the data is invalid OpenPGP data
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, NoSignature::class, BadData::class)
|
||||||
|
fun data(data: InputStream): List<Verification>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide the signed data (without signatures).
|
||||||
|
*
|
||||||
|
* @param data signed data
|
||||||
|
* @return list of signature verifications
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws NoSignature when no valid signature is found
|
||||||
|
* @throws BadData when the data is invalid OpenPGP data
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, NoSignature::class, BadData::class)
|
||||||
|
fun data(data: ByteArray): List<Verification> = data(data.inputStream())
|
||||||
|
}
|
Loading…
Reference in a new issue