mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2024-12-22 12:57:57 +01:00
Kotlin conversion: ExtractCertExternal
This commit is contained in:
parent
c53c69f3ac
commit
01abae4d08
2 changed files with 24 additions and 44 deletions
|
@ -1,44 +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.ExtractCert;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of the {@link ExtractCert} operation using an external SOP binary.
|
|
||||||
*/
|
|
||||||
public class ExtractCertExternal implements ExtractCert {
|
|
||||||
|
|
||||||
private final List<String> commandList = new ArrayList<>();
|
|
||||||
private final List<String> envList;
|
|
||||||
|
|
||||||
public ExtractCertExternal(String binary, Properties properties) {
|
|
||||||
this.commandList.add(binary);
|
|
||||||
this.commandList.add("extract-cert");
|
|
||||||
this.envList = ExternalSOP.propertiesToEnv(properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
|
||||||
public ExtractCert noArmor() {
|
|
||||||
this.commandList.add("--no-armor");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nonnull
|
|
||||||
public Ready key(@Nonnull InputStream keyInputStream) throws SOPGPException.BadData {
|
|
||||||
return ExternalSOP.executeTransformingOperation(Runtime.getRuntime(), commandList, envList, keyInputStream);
|
|
||||||
}
|
|
||||||
}
|
|
24
external-sop/src/main/kotlin/sop/external/operation/ExtractCertExternal.kt
vendored
Normal file
24
external-sop/src/main/kotlin/sop/external/operation/ExtractCertExternal.kt
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// 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.ExtractCert
|
||||||
|
|
||||||
|
/** Implementation of the [ExtractCert] operation using an external SOP binary. */
|
||||||
|
class ExtractCertExternal(binary: String, environment: Properties) : ExtractCert {
|
||||||
|
|
||||||
|
private val commandList = mutableListOf(binary, "extract-cert")
|
||||||
|
private val envList = ExternalSOP.propertiesToEnv(environment)
|
||||||
|
|
||||||
|
override fun noArmor(): ExtractCert = apply { commandList.add("--no-armor") }
|
||||||
|
|
||||||
|
override fun key(keyInputStream: InputStream): Ready =
|
||||||
|
ExternalSOP.executeTransformingOperation(
|
||||||
|
Runtime.getRuntime(), commandList, envList, keyInputStream)
|
||||||
|
}
|
Loading…
Reference in a new issue