if (cluster.getUser() == null) {
throw new AerospikeException("Invalid user");
}
String hash = AdminCommand.hashPassword(password);
AdminCommand command = new AdminCommand();
byte[] userBytes = Buffer.stringToUtf8(user);
if (Arrays.equals(userBytes, cluster.getUser())) {
// Change own password.
command.changePassword(cluster, policy, userBytes, hash);
}
else {
// Change other user's password by user admin.
command.setPassword(cluster, policy, userBytes, hash);
}
cluster.changePassword(userBytes, hash);
}