public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof DelegationCallback) {
DelegationCallback callback = (DelegationCallback) callbacks[i];
Element token = SecurityTokenThreadLocal.getToken();
if (token == null) {
LOG.error("Security token not cached in thread local storage. Check configuration");
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("******************** TOKEN ********************");
LOG.debug(DOM2Writer.nodeToString(token));
LOG.debug("****************** END TOKEN *******************");
}
callback.setToken(token);
}
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}