mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 04:57:56 +01:00
Kotlin conversion: DearmorExternal
This commit is contained in:
parent
d149aac56c
commit
da2b299f4d
2 changed files with 20 additions and 37 deletions
|
@ -1,37 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.external.operation;
|
||||
|
||||
import sop.Ready;
|
||||
import sop.exception.SOPGPException;
|
||||
import sop.external.ExternalSOP;
|
||||
import sop.operation.Dearmor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link Dearmor} operation using an external SOP binary.
|
||||
*/
|
||||
public class DearmorExternal implements Dearmor {
|
||||
|
||||
private final List<String> commandList = new ArrayList<>();
|
||||
private final List<String> envList;
|
||||
|
||||
public DearmorExternal(String binary, Properties environment) {
|
||||
commandList.add(binary);
|
||||
commandList.add("dearmor");
|
||||
envList = ExternalSOP.propertiesToEnv(environment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public Ready data(@Nonnull InputStream data) throws SOPGPException.BadData {
|
||||
return ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, data);
|
||||
}
|
||||
}
|
20
external-sop/src/main/kotlin/sop/external/operation/DearmorExternal.kt
vendored
Normal file
20
external-sop/src/main/kotlin/sop/external/operation/DearmorExternal.kt
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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.Dearmor
|
||||
|
||||
/** Implementation of the [Dearmor] operation using an external SOP binary. */
|
||||
class DearmorExternal(binary: String, environment: Properties) : Dearmor {
|
||||
private val commandList = listOf(binary, "dearmor")
|
||||
private val envList = ExternalSOP.propertiesToEnv(environment)
|
||||
|
||||
override fun data(data: InputStream): Ready =
|
||||
ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, data)
|
||||
}
|
Loading…
Reference in a new issue