mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-08 17:59:43 +02:00
Add list-profiles command
This commit is contained in:
parent
17b305924c
commit
83a003e80f
14 changed files with 216 additions and 0 deletions
|
@ -18,6 +18,7 @@ import sop.external.operation.GenerateKeyExternal;
|
|||
import sop.external.operation.InlineDetachExternal;
|
||||
import sop.external.operation.InlineSignExternal;
|
||||
import sop.external.operation.InlineVerifyExternal;
|
||||
import sop.external.operation.ListProfilesExternal;
|
||||
import sop.external.operation.VersionExternal;
|
||||
import sop.operation.Armor;
|
||||
import sop.operation.Dearmor;
|
||||
|
@ -30,6 +31,7 @@ import sop.operation.GenerateKey;
|
|||
import sop.operation.InlineDetach;
|
||||
import sop.operation.InlineSign;
|
||||
import sop.operation.InlineVerify;
|
||||
import sop.operation.ListProfiles;
|
||||
import sop.operation.Version;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -154,6 +156,11 @@ public class ExternalSOP implements SOP {
|
|||
return new ArmorExternal(binaryName, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListProfiles listProfiles() {
|
||||
return new ListProfilesExternal(binaryName, properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dearmor dearmor() {
|
||||
return new DearmorExternal(binaryName, properties);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
13
external-sop/src/test/java/sop/testsuite/external/operation/ExternalListProfilesTest.java
vendored
Normal file
13
external-sop/src/test/java/sop/testsuite/external/operation/ExternalListProfilesTest.java
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package sop.testsuite.external.operation;
|
||||
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import sop.testsuite.operation.ListProfilesTest;
|
||||
|
||||
@EnabledIf("sop.testsuite.operation.AbstractSOPTest#hasBackends")
|
||||
public class ExternalListProfilesTest extends ListProfilesTest {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue