mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Kotlin conversion: InlineDetach
This commit is contained in:
parent
3e6ebe1cc4
commit
8df4a520bd
2 changed files with 43 additions and 52 deletions
|
@ -1,52 +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 sop.ReadyWithResult;
|
||||
import sop.Signatures;
|
||||
import sop.exception.SOPGPException;
|
||||
|
||||
/**
|
||||
* Split cleartext signed messages up into data and signatures.
|
||||
*/
|
||||
public interface InlineDetach {
|
||||
|
||||
/**
|
||||
* Do not wrap the signatures in ASCII armor.
|
||||
* @return builder
|
||||
*/
|
||||
InlineDetach noArmor();
|
||||
|
||||
/**
|
||||
* Detach the provided signed message from its signatures.
|
||||
*
|
||||
* @param messageInputStream input stream containing the signed message
|
||||
* @return result containing the detached message
|
||||
*
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws sop.exception.SOPGPException.BadData if the input stream does not contain a signed message
|
||||
*/
|
||||
ReadyWithResult<Signatures> message(InputStream messageInputStream)
|
||||
throws IOException,
|
||||
SOPGPException.BadData;
|
||||
|
||||
/**
|
||||
* Detach the provided cleartext signed message from its signatures.
|
||||
*
|
||||
* @param message byte array containing the signed message
|
||||
* @return result containing the detached message
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws sop.exception.SOPGPException.BadData if the byte array does not contain a signed message
|
||||
*/
|
||||
default ReadyWithResult<Signatures> message(byte[] message)
|
||||
throws IOException,
|
||||
SOPGPException.BadData {
|
||||
return message(new ByteArrayInputStream(message));
|
||||
}
|
||||
}
|
43
sop-java/src/main/kotlin/sop/operation/InlineDetach.kt
Normal file
43
sop-java/src/main/kotlin/sop/operation/InlineDetach.kt
Normal file
|
@ -0,0 +1,43 @@
|
|||
// 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.Signatures
|
||||
import sop.exception.SOPGPException.BadData
|
||||
|
||||
interface InlineDetach {
|
||||
|
||||
/**
|
||||
* Do not wrap the signatures in ASCII armor.
|
||||
*
|
||||
* @return builder
|
||||
*/
|
||||
fun noArmor(): InlineDetach
|
||||
|
||||
/**
|
||||
* Detach the provided signed message from its signatures.
|
||||
*
|
||||
* @param messageInputStream input stream containing the signed message
|
||||
* @return result containing the detached message
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws BadData if the input stream does not contain a signed message
|
||||
*/
|
||||
@Throws(IOException::class, BadData::class)
|
||||
fun message(messageInputStream: InputStream): ReadyWithResult<Signatures>
|
||||
|
||||
/**
|
||||
* Detach the provided cleartext signed message from its signatures.
|
||||
*
|
||||
* @param message byte array containing the signed message
|
||||
* @return result containing the detached message
|
||||
* @throws IOException in case of an IO error
|
||||
* @throws BadData if the byte array does not contain a signed message
|
||||
*/
|
||||
@Throws(IOException::class, BadData::class)
|
||||
fun message(message: ByteArray): ReadyWithResult<Signatures> = message(message.inputStream())
|
||||
}
|
Loading…
Reference in a new issue