feat: reorg card cli util
This commit is contained in:
@@ -84,13 +84,7 @@ public class CardCliUtil {
|
|||||||
final String outputs;
|
final String outputs;
|
||||||
final String errorOutputs;
|
final String errorOutputs;
|
||||||
try {
|
try {
|
||||||
final List<String> commandList = new ArrayList<>(pb.command());
|
final List<String> commandList = getDesensitizedCommands(pb);
|
||||||
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, "******");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("Run command: " + StringUtil.join(commandList, " "));
|
log.info("Run command: " + StringUtil.join(commandList, " "));
|
||||||
final Process p = pb.start();
|
final Process p = pb.start();
|
||||||
final byte[] outputsBytes = IOUtil.readToBytes(p.getInputStream());
|
final byte[] outputsBytes = IOUtil.readToBytes(p.getInputStream());
|
||||||
@@ -104,8 +98,19 @@ public class CardCliUtil {
|
|||||||
if (StringUtil.isNotEmpty(StringUtil.trim(errorOutputs))) {
|
if (StringUtil.isNotEmpty(StringUtil.trim(errorOutputs))) {
|
||||||
log.error("Error outputs: " + 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;
|
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