mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 18:29:48 +02:00
Kotlin conversion: RevokeKeyExternal
This commit is contained in:
parent
f2204dfd4d
commit
832a455c4c
2 changed files with 31 additions and 52 deletions
31
external-sop/src/main/kotlin/sop/external/operation/RevokeKeyExternal.kt
vendored
Normal file
31
external-sop/src/main/kotlin/sop/external/operation/RevokeKeyExternal.kt
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.external.operation
|
||||
|
||||
import java.io.InputStream
|
||||
import java.util.Properties
|
||||
import sop.Ready
|
||||
import sop.external.ExternalSOP
|
||||
import sop.operation.RevokeKey
|
||||
|
||||
/** Implementation of the [RevokeKey] operation using an external SOP binary. */
|
||||
class RevokeKeyExternal(binary: String, environment: Properties) : RevokeKey {
|
||||
|
||||
private val commandList = mutableListOf(binary, "revoke-key")
|
||||
private val envList = ExternalSOP.propertiesToEnv(environment).toMutableList()
|
||||
|
||||
private var argCount = 0
|
||||
|
||||
override fun noArmor(): RevokeKey = apply { commandList.add("--no-armor") }
|
||||
|
||||
override fun withKeyPassword(password: ByteArray): RevokeKey = apply {
|
||||
commandList.add("--with-key-password=@ENV:KEY_PASSWORD_$argCount")
|
||||
envList.add("KEY_PASSWORD_$argCount=${String(password)}")
|
||||
argCount += 1
|
||||
}
|
||||
|
||||
override fun keys(keys: InputStream): Ready =
|
||||
ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, keys)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue