RealmCallback rcb = (RealmCallback) current;
String defaultText = rcb.getDefaultText();
realm = defaultText;
rcb.setText(defaultText); // For now just use the realm suggested.
} else if (current instanceof RealmChoiceCallback) {
throw new UnsupportedCallbackException(current, "Realm choice not currently supported.");
} else if (current instanceof NameCallback) {
NameCallback ncb = (NameCallback) current;
if (username == null) {
showRealm();
username = readLine("Username: ", false, true);
if (username == null || username.length() == 0) {
throw new SaslException("No username supplied.");
}
}
ncb.setName(username);
} else if (current instanceof PasswordCallback && digest == null) {
// If a digest had been set support for PasswordCallback is disabled.
PasswordCallback pcb = (PasswordCallback) current;
if (password == null) {
showRealm();
String temp = readLine("Password: ", true, false);
if (temp != null) {
password = temp.toCharArray();
}
}
pcb.setPassword(password);
} else if (current instanceof DigestHashCallback && digest != null) {
// We don't support an interactive use of this callback so it must have been set in advance.
DigestHashCallback dhc = (DigestHashCallback) current;
dhc.setHexHash(digest);
} else {
printLine("Unexpected Callback " + current.getClass().getName());
throw new UnsupportedCallbackException(current);
}
}
}