if (current instanceof AuthorizeCallback) {
toRespondTo.add(current);
} else if (current instanceof NameCallback) {
NameCallback nameCallback = (NameCallback) current;
userName = nameCallback.getDefaultName();
Identity identity = ap.loadIdentity(userName, realmName);
if (identity != null) {
credential = identity.getCredential();
}
} else if (current instanceof PasswordCallback) {
toRespondTo.add(current);
} else if (current instanceof DigestHashCallback) {
toRespondTo.add(current);