try {
File serverDir = new File(nodeDir,node);
if (serverDir == null || !serverDir.isDirectory()) {
throw new CommandException(strings.get("bad.node.dir",serverDir));
}
String serverName = getServerDirs().getServerName();
HostAndPort adminAddress = getAdminAddress(serverName);
if (isRunning(adminAddress.getHost(), adminAddress.getPort()))
throw new CommandException(strings.get("instance.is.running",
serverName));
oldPassword = passwords.get("AS_ADMIN_MASTERPASSWORD");
if (oldPassword == null) {
oldPassword = super.readPassword(strings.get("old.mp"));
}
if (oldPassword == null)
throw new CommandException(strings.get("no.console"));
// for each instance iterate through the instances first,
// read each keystore with the old password,
// only then should it save the new master password.
boolean valid = true;
for(String instanceDir: getInstanceDirs(nodeDirChild)) {
valid &= verifyInstancePassword(new File(nodeDirChild,instanceDir));
}
if (!valid) {
throw new CommandException(strings.get("incorrect.old.mp"));
}
ParamModelData nmpo = new ParamModelData("AS_ADMIN_NEWMASTERPASSWORD",
String.class, false, null);
nmpo.description = strings.get("new.mp");
nmpo.param._password = true;
newPassword = super.getPassword(nmpo, null, true);
// for each instance encrypt the keystore
for(String instanceDir: getInstanceDirs(nodeDirChild)) {
encryptKeystore(instanceDir);
}
if (savemp) {
createMasterPasswordFile();
}
return 0;
} catch(Exception e) {
throw new CommandException(e.getMessage(),e);
}
}