}
// Step 1 - Create Callbacks
RealmCallback rcb = new RealmCallback("Realm", realm);
NameCallback ncb = new NameCallback("Username", username);
Callback credentialCallback = preDigested ? new DigestHashCallback("Password Digest") : new PasswordCallback("Password", false);
Callback[] callbacks = new Callback[]{rcb, ncb, credentialCallback};
// Step 2 - Call CallbackHandler
try {
callbackHandler.handle(callbacks);
} catch (UserNotFoundException e) {
if (ROOT_LOGGER.isDebugEnabled()) {
ROOT_LOGGER.debug(e.getMessage());
}
return null;
} catch (IOException e) {
throw MESSAGES.invalidCallbackHandler();
} catch (UnsupportedCallbackException e) {
throw MESSAGES.invalidCallbackHandler();
}
// TODO - Verify that a password was set (Depending on if multiple CallbackHandlers are supported)
// Step 3 - Generate MD5 and Compare
try {
// TODO - The remaining combinations from RFC-2617 need to be added.
// TODO - Verify all required parameters were set.
MessageDigest md = MessageDigest.getInstance(MD5);
byte[] ha1;
if (preDigested) {
DigestHashCallback dhc = (DigestHashCallback) credentialCallback;
ha1 = dhc.getHexHash().getBytes();
} else {
md.update(challengeParameters.get(USERNAME).getBytes());
md.update(COLON);
md.update(challengeParameters.get(REALM).getBytes());
md.update(COLON);