Class ChangeNodeMasterPasswordCommand
- java.lang.Object
-
- com.sun.enterprise.admin.cli.CLICommand
-
- com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
-
- com.sun.enterprise.admin.cli.cluster.LocalInstanceCommand
-
- com.sun.enterprise.admin.cli.cluster.ChangeNodeMasterPasswordCommand
-
- All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct
@Service(name="_change-master-password-node") @PerLookup public class ChangeNodeMasterPasswordCommand extends LocalInstanceCommand
The change-master-password command for a node. It takes in a nodeDir and node name- Author:
- Bhakti Mehta, Matt Gill
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
NEW_PASSWORD_ALIAS
protected String
node
protected static String
OLD_PASSWORD_ALIAS
protected File
selectedNodeDir
-
Fields inherited from class com.sun.enterprise.admin.cli.cluster.LocalInstanceCommand
checkOneAndOnly, domainName, instanceDir, instanceName, isCreateInstanceFilesystem, nodeDir, nodeDirChild, nodeDirRoot
-
Fields inherited from class com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
DEFAULT_MASTER_PASSWORD
-
Fields inherited from class com.sun.enterprise.admin.cli.CLICommand
argv, ASADMIN, commandModel, CONNECTION_ERROR, env, ERROR, INVALID_COMMAND_ERROR, lineReader, logger, metadataErrors, name, operands, options, passwords, programOpts, SUCCESS, terminal, WARNING
-
-
Constructor Summary
Constructors Constructor Description ChangeNodeMasterPasswordCommand()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
execute(String... argv)
Execute this command with the given arguemnts.protected int
executeCommand()
Execute the command using the options in options and the operands in operands.protected String
findOldPassword()
Find the old password from the property in the password file with the nameOLD_PASSWORD_ALIAS
if it exists, or by prompting the user otherwise.protected void
inject()
Inject this instance with the final values of all the command parameters.protected void
setNewPassword()
Set thenewPassword
field from the property in the password file with the nameOLD_PASSWORD_ALIAS
if it exists, or by prompting the user twice otherwise.protected void
validate()
The validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.-
Methods inherited from class com.sun.enterprise.admin.cli.cluster.LocalInstanceCommand
getDasProperties, getInstanceDirs, getInstanceName, getMasterPasswordFile, getNodeInstallDir, getNodeProperties, getProductRootPath, initInstance, isDirectory, mkdirs, setDasDefaults, setInstanceName, setServerDirs, validateDasOptions, whackFilesystem
-
Methods inherited from class com.sun.enterprise.admin.servermgmt.cli.LocalServerCommand
checkAdditionalTrustAndKeyStores, checkForSpecialFiles, dataGridEncryptionEnabled, getAdminAddress, getAdminAddress, getDomainXml, getInstallRootPath, getMasterPassword, getPrevPid, getServerDirs, getServerPid, getUptime, isLocal, isRemote, isRestartable, isRunning, isRunning, isThisServer, loadAndVerifyKeystore, readFromMasterPasswordFile, resetServerDirs, setLocalPassword, setServerDirs, unsetLocalPassword, verifyMasterPassword, waitForRestart, waitForRestart
-
Methods inherited from class com.sun.enterprise.admin.cli.CLICommand
buildLineReader, buildTerminal, checkHelp, closeTerminal, execute, expandManPage, getBooleanOption, getBriefCommandUsage, getCommand, getCommand, getCommandScope, getCommandUsage, getManPage, getName, getOperandModel, getOption, getOptions, getPassword, getPassword, getProgramOptions, getSystemProperties, getSystemProperty, getUsage, initializeLogger, initializePasswords, newLineReaderBuilder, ok, parse, postConstruct, prepare, prevalidate, printExceptionStackTrace, processProgramOptions, quote, readPassword, setCommandScope, toString, usageOptions
-
-
-
-
Field Detail
-
OLD_PASSWORD_ALIAS
protected static final String OLD_PASSWORD_ALIAS
- See Also:
- Constant Field Values
-
NEW_PASSWORD_ALIAS
protected static final String NEW_PASSWORD_ALIAS
- See Also:
- Constant Field Values
-
node
protected String node
-
selectedNodeDir
protected File selectedNodeDir
-
-
Method Detail
-
inject
protected void inject() throws CommandException
Description copied from class:CLICommand
Inject this instance with the final values of all the command parameters.- Overrides:
inject
in classCLICommand
- Throws:
CommandException
- if execution of the command failsCommandValidationException
- if there's something wrong with the options or arguments
-
validate
protected void validate() throws CommandException, CommandValidationException
Description copied from class:CLICommand
The validate method can be used by a subclass to validate that the type and quantity of parameters and operands matches the requirements for this command.- Overrides:
validate
in classLocalInstanceCommand
- Throws:
CommandException
- if execution of the command failsCommandValidationException
- if there's something wrong with the options or arguments
-
executeCommand
protected int executeCommand() throws CommandException
Description copied from class:CLICommand
Execute the command using the options in options and the operands in operands.- Specified by:
executeCommand
in classCLICommand
- Returns:
- the exit code
- Throws:
CommandException
- if execution of the command failsCommandValidationException
- if there's something wrong with the options or arguments
-
execute
public int execute(String... argv) throws CommandException
Description copied from class:CLICommand
Execute this command with the given arguemnts. The implementation in this class saves the passed arguments in the argv field and calls the initializePasswords method. Then it calls the prepare, parse, and validate methods, finally returning the result of calling the executeCommand method. Note that argv[0] is the command name.- Overrides:
execute
in classCLICommand
- Parameters:
argv
- Arguments to execute command with- Returns:
- exit code of the command
- Throws:
CommandException
- if execution of the command failsCommandValidationException
- if there's something wrong with the options or arguments
-
findOldPassword
protected String findOldPassword() throws CommandException
Find the old password from the property in the password file with the nameOLD_PASSWORD_ALIAS
if it exists, or by prompting the user otherwise.- Throws:
CommandException
- if the password is null
-
setNewPassword
protected void setNewPassword() throws CommandException
Set thenewPassword
field from the property in the password file with the nameOLD_PASSWORD_ALIAS
if it exists, or by prompting the user twice otherwise.- Throws:
CommandException
- if the passwords don't match or are null
-
-