for (int i=0; i < callbacks.length; i++) {
Callback callback = callbacks[i];
if (callback instanceof NameCallback) {
handleUsernameCallback((NameCallback)callback);
} else if (callback instanceof PasswordCallback) {
handlePasswordCallback((PasswordCallback)callback);
}else{
throw new UnsupportedCallbackException(callback, "Unknow callback for username or password");
}
}