in kerby-tool/kdc-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/command/DeletePrincipalCommand.java [44:77]
public void execute(String input) {
String[] commands = input.split(" ");
if (commands.length < 2) {
System.err.println(USAGE);
return;
}
parseOptions(commands);
String principal = commands[commands.length - 1];
if (force) {
deletePrincipal(getKadmin(), principal);
} else {
String reply;
Console console = System.console();
String prompt = "Are you sure want to delete the principal? (yes/no, YES/NO, y/n, Y/N) ";
if (console == null) {
System.out.println("Couldn't get Console instance, "
+ "maybe you're running this from within an IDE. "
+ "Use scanner to read password.");
Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8.name());
reply = getReply(scanner, prompt);
} else {
reply = getReply(console, prompt);
}
if (reply.equals("yes") || reply.equals("YES") || reply.equals("y") || reply.equals("Y")) {
deletePrincipal(getKadmin(), principal);
} else if (reply.equals("no") || reply.equals("NO") || reply.equals("n") || reply.equals("N")) {
System.out.println("Principal \"" + principal + "\" not deleted.");
} else {
System.err.println("Unknow request, fail to delete the principal.");
}
}
}