mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-22 23:22:05 +01:00
Kotlin conversion: DetachedSign
This commit is contained in:
parent
91a861b5c3
commit
4dc1779a06
2 changed files with 50 additions and 61 deletions
|
@ -1,61 +0,0 @@
|
||||||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
||||||
//
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
package sop.operation;
|
|
||||||
|
|
||||||
import sop.ReadyWithResult;
|
|
||||||
import sop.SigningResult;
|
|
||||||
import sop.enums.SignAs;
|
|
||||||
import sop.exception.SOPGPException;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
public interface DetachedSign extends AbstractSign<DetachedSign> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the signature mode.
|
|
||||||
* Note: This method has to be called before {@link #key(InputStream)} is called.
|
|
||||||
*
|
|
||||||
* @param mode signature mode
|
|
||||||
* @return builder instance
|
|
||||||
*
|
|
||||||
* @throws sop.exception.SOPGPException.UnsupportedOption if this option is not supported
|
|
||||||
*/
|
|
||||||
DetachedSign mode(SignAs mode)
|
|
||||||
throws SOPGPException.UnsupportedOption;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signs data.
|
|
||||||
*
|
|
||||||
* @param data input stream containing data
|
|
||||||
* @return ready
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws sop.exception.SOPGPException.KeyIsProtected if at least one signing key cannot be unlocked
|
|
||||||
* @throws sop.exception.SOPGPException.ExpectedText if text data was expected, but binary data was encountered
|
|
||||||
*/
|
|
||||||
ReadyWithResult<SigningResult> data(InputStream data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.KeyIsProtected,
|
|
||||||
SOPGPException.ExpectedText;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Signs data.
|
|
||||||
*
|
|
||||||
* @param data byte array containing data
|
|
||||||
* @return ready
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws sop.exception.SOPGPException.KeyIsProtected if at least one signing key cannot be unlocked
|
|
||||||
* @throws sop.exception.SOPGPException.ExpectedText if text data was expected, but binary data was encountered
|
|
||||||
*/
|
|
||||||
default ReadyWithResult<SigningResult> data(byte[] data)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.KeyIsProtected,
|
|
||||||
SOPGPException.ExpectedText {
|
|
||||||
return data(new ByteArrayInputStream(data));
|
|
||||||
}
|
|
||||||
}
|
|
50
sop-java/src/main/kotlin/sop/operation/DetachedSign.kt
Normal file
50
sop-java/src/main/kotlin/sop/operation/DetachedSign.kt
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// 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.SigningResult
|
||||||
|
import sop.enums.SignAs
|
||||||
|
import sop.exception.SOPGPException.*
|
||||||
|
|
||||||
|
interface DetachedSign : AbstractSign<DetachedSign> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the signature mode. Note: This method has to be called before [key] is called.
|
||||||
|
*
|
||||||
|
* @param mode signature mode
|
||||||
|
* @return builder instance
|
||||||
|
* @throws UnsupportedOption if this option is not supported
|
||||||
|
*/
|
||||||
|
@Throws(UnsupportedOption::class) fun mode(mode: SignAs): DetachedSign
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signs data.
|
||||||
|
*
|
||||||
|
* @param data input stream containing data
|
||||||
|
* @return ready
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws KeyIsProtected if at least one signing key cannot be unlocked
|
||||||
|
* @throws ExpectedText if text data was expected, but binary data was encountered
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, KeyIsProtected::class, ExpectedText::class)
|
||||||
|
fun data(data: InputStream): ReadyWithResult<SigningResult>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signs data.
|
||||||
|
*
|
||||||
|
* @param data byte array containing data
|
||||||
|
* @return ready
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws sop.exception.SOPGPException.KeyIsProtected if at least one signing key cannot be
|
||||||
|
* unlocked
|
||||||
|
* @throws sop.exception.SOPGPException.ExpectedText if text data was expected, but binary data
|
||||||
|
* was encountered
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, KeyIsProtected::class, ExpectedText::class)
|
||||||
|
fun data(data: ByteArray): ReadyWithResult<SigningResult> = data(data.inputStream())
|
||||||
|
}
|
Loading…
Reference in a new issue