mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-08 17:59:43 +02:00
Kotlin conversion: ArmorExternal
This commit is contained in:
parent
1c0666b4e1
commit
6771952618
2 changed files with 26 additions and 46 deletions
26
external-sop/src/main/kotlin/sop/external/operation/ArmorExternal.kt
vendored
Normal file
26
external-sop/src/main/kotlin/sop/external/operation/ArmorExternal.kt
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
// 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.enums.ArmorLabel
|
||||
import sop.exception.SOPGPException
|
||||
import sop.external.ExternalSOP
|
||||
import sop.operation.Armor
|
||||
|
||||
/** Implementation of the [Armor] operation using an external SOP binary. */
|
||||
class ArmorExternal(binary: String, environment: Properties) : Armor {
|
||||
|
||||
private val commandList: MutableList<String> = mutableListOf(binary, "armor")
|
||||
private val envList: List<String> = ExternalSOP.propertiesToEnv(environment)
|
||||
|
||||
override fun label(label: ArmorLabel): Armor = apply { commandList.add("--label=$label") }
|
||||
|
||||
@Throws(SOPGPException.BadData::class)
|
||||
override fun data(data: InputStream): Ready =
|
||||
ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, data)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue