mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-11-25 16:42:07 +01:00
Kotlin conversion: RevokeKey
This commit is contained in:
parent
145cadef4f
commit
0ee4638beb
2 changed files with 48 additions and 54 deletions
|
@ -1,54 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.operation;
|
||||
|
||||
import sop.Ready;
|
||||
import sop.exception.SOPGPException;
|
||||
import sop.util.UTF8Util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface RevokeKey {
|
||||
|
||||
/**
|
||||
* Disable ASCII armor encoding.
|
||||
*
|
||||
* @return builder instance
|
||||
*/
|
||||
RevokeKey noArmor();
|
||||
|
||||
/**
|
||||
* Provide the decryption password for the secret key.
|
||||
*
|
||||
* @param password password
|
||||
* @return builder instance
|
||||
* @throws SOPGPException.UnsupportedOption if the implementation does not support key passwords
|
||||
* @throws SOPGPException.PasswordNotHumanReadable if the password is not human-readable
|
||||
*/
|
||||
default RevokeKey withKeyPassword(String password)
|
||||
throws SOPGPException.UnsupportedOption,
|
||||
SOPGPException.PasswordNotHumanReadable {
|
||||
return withKeyPassword(password.getBytes(UTF8Util.UTF8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the decryption password for the secret key.
|
||||
*
|
||||
* @param password password
|
||||
* @return builder instance
|
||||
* @throws SOPGPException.UnsupportedOption if the implementation does not support key passwords
|
||||
* @throws SOPGPException.PasswordNotHumanReadable if the password is not human-readable
|
||||
*/
|
||||
RevokeKey withKeyPassword(byte[] password)
|
||||
throws SOPGPException.UnsupportedOption,
|
||||
SOPGPException.PasswordNotHumanReadable;
|
||||
|
||||
default Ready keys(byte[] bytes) {
|
||||
return keys(new ByteArrayInputStream(bytes));
|
||||
}
|
||||
|
||||
Ready keys(InputStream keys);
|
||||
}
|
48
sop-java/src/main/kotlin/sop/operation/RevokeKey.kt
Normal file
48
sop-java/src/main/kotlin/sop/operation/RevokeKey.kt
Normal file
|
@ -0,0 +1,48 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.operation
|
||||
|
||||
import java.io.InputStream
|
||||
import sop.Ready
|
||||
import sop.exception.SOPGPException.PasswordNotHumanReadable
|
||||
import sop.exception.SOPGPException.UnsupportedOption
|
||||
import sop.util.UTF8Util
|
||||
|
||||
interface RevokeKey {
|
||||
|
||||
/**
|
||||
* Disable ASCII armor encoding.
|
||||
*
|
||||
* @return builder instance
|
||||
*/
|
||||
fun noArmor(): RevokeKey
|
||||
|
||||
/**
|
||||
* Provide the decryption password for the secret key.
|
||||
*
|
||||
* @param password password
|
||||
* @return builder instance
|
||||
* @throws UnsupportedOption if the implementation does not support key passwords
|
||||
* @throws PasswordNotHumanReadable if the password is not human-readable
|
||||
*/
|
||||
@Throws(UnsupportedOption::class, PasswordNotHumanReadable::class)
|
||||
fun withKeyPassword(password: String): RevokeKey =
|
||||
withKeyPassword(password.toByteArray(UTF8Util.UTF8))
|
||||
|
||||
/**
|
||||
* Provide the decryption password for the secret key.
|
||||
*
|
||||
* @param password password
|
||||
* @return builder instance
|
||||
* @throws UnsupportedOption if the implementation does not support key passwords
|
||||
* @throws PasswordNotHumanReadable if the password is not human-readable
|
||||
*/
|
||||
@Throws(UnsupportedOption::class, PasswordNotHumanReadable::class)
|
||||
fun withKeyPassword(password: ByteArray): RevokeKey
|
||||
|
||||
fun keys(bytes: ByteArray): Ready = keys(bytes.inputStream())
|
||||
|
||||
fun keys(keys: InputStream): Ready
|
||||
}
|
Loading…
Reference in a new issue