feat: reorg card cli util
This commit is contained in:
@@ -84,13 +84,7 @@ public class CardCliUtil {
|
||||
final String outputs;
|
||||
final String errorOutputs;
|
||||
try {
|
||||
final List<String> commandList = new ArrayList<>(pb.command());
|
||||
for (int i = 0; i < commandList.size(); i++) {
|
||||
final String c = commandList.get(i);
|
||||
if (StringUtil.equals("--pin", c) && ((i + 1) < commandList.size())) {
|
||||
commandList.set(i + 1, "******");
|
||||
}
|
||||
}
|
||||
final List<String> commandList = getDesensitizedCommands(pb);
|
||||
log.info("Run command: " + StringUtil.join(commandList, " "));
|
||||
final Process p = pb.start();
|
||||
final byte[] outputsBytes = IOUtil.readToBytes(p.getInputStream());
|
||||
@@ -104,8 +98,19 @@ public class CardCliUtil {
|
||||
if (StringUtil.isNotEmpty(StringUtil.trim(errorOutputs))) {
|
||||
log.error("Error outputs: " + errorOutputs);
|
||||
}
|
||||
throw new RuntimeException("Outputs is empty!");
|
||||
throw new RuntimeException("Outputs is empty! Please insert or reinsert your card.");
|
||||
}
|
||||
return outputs;
|
||||
}
|
||||
|
||||
private static List<String> getDesensitizedCommands(ProcessBuilder pb) {
|
||||
final List<String> commandList = new ArrayList<>(pb.command());
|
||||
for (int i = 0; i < commandList.size(); i++) {
|
||||
final String c = commandList.get(i);
|
||||
if (StringUtil.equals("--pin", c) && ((i + 1) < commandList.size())) {
|
||||
commandList.set(i + 1, "******");
|
||||
}
|
||||
}
|
||||
return commandList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user