in kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/command/RemoteRenamePrincipalCommand.java [43:74]
public void execute(String input) throws KrbException {
String[] items = input.split("\\s+");
if (items.length < 3) {
System.err.println(USAGE);
return;
}
String adminRealm = adminClient.getAdminConfig().getAdminRealm();
String oldPrincipalName = items[items.length - 2] + "@" + adminRealm;
String newPrincipalName = items[items.length - 1] + "@" + adminRealm;
String reply;
Console console = System.console();
String prompt = "Are you sure to rename 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")) {
adminClient.requestRenamePrincipal(oldPrincipalName, newPrincipalName);
} else if (reply.equals("no") || reply.equals("NO") || reply.equals("n") || reply.equals("N")) {
System.out.println("Principal \"" + oldPrincipalName + "\" not renamed.");
} else {
System.err.println("Unknown request, fail to rename the principal.");
System.err.println(USAGE);
}
}