ChangeAdminPasswordCommandpublic class ChangeAdminPasswordCommand extends S1ASCommand This class gets called when change-admin-password command is invoked.
CLI will prompt the user for the password. |
Fields Summary |
---|
private static final String | ADMIN_PASSWORD | private static final String | PASSWORD | private static final String | INTERACTIVE | private static final String | OLD_ADMIN_PASSWORD | private static final String | NEW_ADMIN_PASSWORD | private String | newPassword | private String | oldPassword |
Methods Summary |
---|
private java.lang.String | getNewAdminPassword()
return getPassword(NEW_ADMIN_PASSWORD,
"NewAdminPasswordPrompt", "NewAdminPasswordConfirmationPrompt",
false, false, false, false, null, null,
true, true, true, false);
| private java.lang.String | getOldAdminPassword()
return getPassword(OLD_ADMIN_PASSWORD,
"OldAdminPasswordPrompt", null,
false, false, false, false, null, null,
true, false, true, false);
| public void | runCommand()executes the command
if (!validateOptions())
throw new CommandValidationException("Validation is false");
final String host = getHost();
final int port = getPort();
final String userName = getUser();
//use http connector
MBeanServerConnection mbsc = getMBeanServerConnection(host, port, userName, oldPassword);
final String objectName = getObjectName();
final Object[] params = getParamsInfo();
final String operationName = getOperationName();
final String[] types = getTypesInfo();
try
{
//if (System.getProperty("Debug") != null) printDebug(mbsc, objectName);
Object returnValue = mbsc.invoke(new ObjectName(objectName),
operationName, params, types);
handleReturnValue(returnValue);
updateLoginFile(userName, host, port);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"CommandSuccessful",
new Object[] {name}));
}
catch(Exception e)
{
displayExceptionMessage(e);
}
| private void | updateLoginFile(java.lang.String user, java.lang.String host, int port)
try {
final LoginInfoStore store = LoginInfoStoreFactory.getStore(null);
if (store.exists(host, port))
{
store.store(new LoginInfo(host, port, user, newPassword), true);
CLILogger.getInstance().printDetailMessage(getLocalizedString(
"SuccessfullyUpdatedLoginInfo"));
}
}
catch(final Exception e) {
//ignore message if unable to update .asadminpass
}
| public boolean | validateOptions()This method prompts the user for the old and new adminpassword.
super.validateOptions();
try {
/**
* set interactive to true so that passwords can be prompted.
**/
setOption(INTERACTIVE, "true");
//if user is not entered on command line, prompt for the user name.
final String sUser = getUser();
setOption(USER, sUser);
oldPassword = getOldAdminPassword();
setOption(PASSWORD, oldPassword);
newPassword = getNewAdminPassword();
setOption(ADMIN_PASSWORD, newPassword);
}
catch (CommandException ce) {
throw new CommandValidationException(ce.getLocalizedMessage());
}
return true;
|
|