username = ((NameCallback) callbacks[0]).getName();
if (username == null || username.equals("")) {
// Clear out the private state
username = null;
password = null;
throw new FailedLoginException();
}
String realPassword = users.getProperty(username);
if (realPassword == null || realPassword.equals("")) {
// Clear out the private state
username = null;
password = null;
throw new FailedLoginException();
} else {
// Decrypt the password if needed, so we can compare it with the supplied one
realPassword = (String) EncryptionManager.decrypt(realPassword);
}
char[] entered = ((PasswordCallback) callbacks[1]).getPassword();
password = entered == null ? null : new String(entered);
if (!checkPassword(realPassword, password)) {
// Clear out the private state
username = null;
password = null;
throw new FailedLoginException();
}
loginSucceeded = true;
return true;
}