feat: pinentry-cli more funcs
This commit is contained in:
@@ -16,10 +16,6 @@ public class PinEntryTool {
|
||||
private String pinEntry = null;
|
||||
private boolean disableFallbackCli = false;
|
||||
|
||||
public static void main(String[] args) throws PinEntryException {
|
||||
System.out.println(PinEntryTool.instance().getPin());
|
||||
}
|
||||
|
||||
public static PinEntryTool instance() {
|
||||
return new PinEntryTool();
|
||||
}
|
||||
@@ -43,6 +39,25 @@ public class PinEntryTool {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDefaultPinOrInputWithoutThrows(String defaultPin) {
|
||||
try {
|
||||
return getDefaultPinOrInput(defaultPin);
|
||||
} catch (PinEntryException e) {
|
||||
throw new RuntimeException("Get default PIN or input field: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDefaultPinOrInput(String defaultPin) throws PinEntryException {
|
||||
return getDefaultPinOrInput(defaultPin, null, null);
|
||||
}
|
||||
|
||||
public String getDefaultPinOrInput(String defaultPin, String description, String prompt) throws PinEntryException {
|
||||
if (StringUtil.isNotEmpty(defaultPin)) {
|
||||
return defaultPin;
|
||||
}
|
||||
return getPin(description, prompt);
|
||||
}
|
||||
|
||||
public String getPin() throws PinEntryException {
|
||||
return getPin(null, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user