mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-25 16:42:07 +01:00
Kotlin conversion: ExtractCert
This commit is contained in:
parent
41db9d2ac7
commit
653675f730
2 changed files with 42 additions and 50 deletions
|
@ -1,50 +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.Ready;
|
|
||||||
import sop.exception.SOPGPException;
|
|
||||||
|
|
||||||
public interface ExtractCert {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable ASCII armor encoding.
|
|
||||||
*
|
|
||||||
* @return builder instance
|
|
||||||
*/
|
|
||||||
ExtractCert noArmor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract the cert(s) from the provided key(s).
|
|
||||||
*
|
|
||||||
* @param keyInputStream input stream containing the encoding of one or more OpenPGP keys
|
|
||||||
* @return result containing the encoding of the keys certs
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws sop.exception.SOPGPException.BadData if the {@link InputStream} does not contain an OpenPGP key
|
|
||||||
*/
|
|
||||||
Ready key(InputStream keyInputStream)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.BadData;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract the cert(s) from the provided key(s).
|
|
||||||
*
|
|
||||||
* @param key byte array containing the encoding of one or more OpenPGP key
|
|
||||||
* @return result containing the encoding of the keys certs
|
|
||||||
*
|
|
||||||
* @throws IOException in case of an IO error
|
|
||||||
* @throws sop.exception.SOPGPException.BadData if the byte array does not contain an OpenPGP key
|
|
||||||
*/
|
|
||||||
default Ready key(byte[] key)
|
|
||||||
throws IOException,
|
|
||||||
SOPGPException.BadData {
|
|
||||||
return key(new ByteArrayInputStream(key));
|
|
||||||
}
|
|
||||||
}
|
|
42
sop-java/src/main/kotlin/sop/operation/ExtractCert.kt
Normal file
42
sop-java/src/main/kotlin/sop/operation/ExtractCert.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.ByteArrayInputStream
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InputStream
|
||||||
|
import sop.Ready
|
||||||
|
import sop.exception.SOPGPException.BadData
|
||||||
|
|
||||||
|
interface ExtractCert {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable ASCII armor encoding.
|
||||||
|
*
|
||||||
|
* @return builder instance
|
||||||
|
*/
|
||||||
|
fun noArmor(): ExtractCert
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the cert(s) from the provided key(s).
|
||||||
|
*
|
||||||
|
* @param keyInputStream input stream containing the encoding of one or more OpenPGP keys
|
||||||
|
* @return result containing the encoding of the keys certs
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws BadData if the [InputStream] does not contain an OpenPGP key
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, BadData::class) fun key(keyInputStream: InputStream): Ready
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract the cert(s) from the provided key(s).
|
||||||
|
*
|
||||||
|
* @param key byte array containing the encoding of one or more OpenPGP key
|
||||||
|
* @return result containing the encoding of the keys certs
|
||||||
|
* @throws IOException in case of an IO error
|
||||||
|
* @throws BadData if the byte array does not contain an OpenPGP key
|
||||||
|
*/
|
||||||
|
@Throws(IOException::class, BadData::class)
|
||||||
|
fun key(key: ByteArray): Ready = key(ByteArrayInputStream(key))
|
||||||
|
}
|
Loading…
Reference in a new issue