logger.fine("handle callback i " + i + ": " + callbacks[i]);
if (callbacks[i] instanceof TextOutputCallback) {
logger.fine("skip text output callback " + callbacks[i]);
continue;
} else if (callbacks[i] instanceof NameCallback) {
NameCallback cb = (NameCallback) callbacks[i];
// if (cb.getPrompt().indexOf("alias") >= 0) {
logger.fine("user.name: " + System.getProperty("user.name"));
cb.setName(System.getProperty("user.name"));
// } else {
// logger.fine("cb.getPrompt(): " + cb.getPrompt());
// throw new UnsupportedCallbackException(callbacks[i]);
// }
} else if (callbacks[i] instanceof PasswordCallback) {
PasswordCallback cb = (PasswordCallback) callbacks[i];
if (usePW) {
// TODO: replace by native func to suppress password echo
System.out.print(cb.getPrompt() + " ");
System.out.flush();
String pw = new BufferedReader(new InputStreamReader(System.in)).readLine();
cb.setPassword(pw.toCharArray());
pw = null;
} else {
cb.setPassword(new char[0]);
}
} else if (callbacks[i] instanceof ConfirmationCallback) {
ConfirmationCallback cb = (ConfirmationCallback) callbacks[i];
cb.setSelectedIndex(cb.getDefaultOption());
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}