public void handle (Callback[] callbacks)
throws UnsupportedCallbackException, IOException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof TextOutputCallback) {
// display the message according to the specified type
TextOutputCallback toc
= (TextOutputCallback)callbacks[i];
switch (toc.getMessageType()) {
case TextOutputCallback.INFORMATION:
if (logger.isInfoEnabled()) {
logger.info(toc.getMessage());
}
break;
case TextOutputCallback.ERROR:
logger.error("ERROR: " + toc.getMessage());
break;
case TextOutputCallback.WARNING:
logger.warn("WARNING: " + toc.getMessage());
break;
default:
throw new IOException
("Unsupported message type: "
+ toc.getMessageType());
}
} else if (callbacks[i] instanceof NameCallback) {
// prompt the user for a username
NameCallback nc = (NameCallback)callbacks[i];
nc.setName(userName);