mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-09 10:19:47 +02:00
Add list-profiles command
This commit is contained in:
parent
17b305924c
commit
83a003e80f
14 changed files with 216 additions and 0 deletions
|
@ -51,6 +51,12 @@ public class GenerateKeyExternal implements GenerateKey {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerateKey profile(String profile) {
|
||||
commandList.add("--profile=" + profile);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ready generate()
|
||||
throws SOPGPException.MissingArg, SOPGPException.UnsupportedAsymmetricAlgo {
|
||||
|
|
47
external-sop/src/main/java/sop/external/operation/ListProfilesExternal.java
vendored
Normal file
47
external-sop/src/main/java/sop/external/operation/ListProfilesExternal.java
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.external.operation;
|
||||
|
||||
import sop.external.ExternalSOP;
|
||||
import sop.operation.ListProfiles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ListProfilesExternal extends ListProfiles {
|
||||
|
||||
private final List<String> commandList = new ArrayList<>();
|
||||
private final List<String> envList;
|
||||
|
||||
public ListProfilesExternal(String binary, Properties properties) {
|
||||
this.commandList.add(binary);
|
||||
this.commandList.add("list-profiles");
|
||||
this.envList = ExternalSOP.propertiesToEnv(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ofCommand(String command) {
|
||||
commandList.add(command);
|
||||
try {
|
||||
String output = new String(ExternalSOP.executeProducingOperation(Runtime.getRuntime(), commandList, envList).getBytes());
|
||||
return Arrays.asList(output.split("\n"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> global() {
|
||||
try {
|
||||
String output = new String(ExternalSOP.executeProducingOperation(Runtime.getRuntime(), commandList, envList).getBytes());
|
||||
return Arrays.asList(output.split("\n"));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue