Package org.elasticsearch.cli
Class KeyStoreAwareCommand
java.lang.Object
org.elasticsearch.cli.Command
org.elasticsearch.cli.EnvironmentAwareCommand
org.elasticsearch.cli.KeyStoreAwareCommand
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
BaseKeyStoreCommand,HasPasswordKeyStoreCommand
An
EnvironmentAwareCommand that needs to access the elasticsearch keystore, possibly
decrypting it if it is password protected.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intArbitrarily chosen maximum passphrase lengthFields inherited from class org.elasticsearch.cli.Command
description, parser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voiddecryptKeyStore(KeyStoreWrapper keyStore, org.elasticsearch.cli.Terminal terminal)Decrypt thekeyStore, prompting the user to enter the password in theTerminalif it is password protectedprotected abstract voidexecute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env)Execute the command with the initializedEnvironment.protected static SecureStringreadPassword(org.elasticsearch.cli.Terminal terminal, boolean withVerification)Reads the keystore password from theTerminal, prompting for verification where applicable and returns it as aSecureString.Methods inherited from class org.elasticsearch.cli.EnvironmentAwareCommand
createEnv, createEnv, executeMethods inherited from class org.elasticsearch.cli.Command
addShutdownHook, close, exit, main, printAdditionalHelp
-
Field Details
-
MAX_PASSPHRASE_LENGTH
public static final int MAX_PASSPHRASE_LENGTHArbitrarily chosen maximum passphrase length- See Also:
- Constant Field Values
-
-
Constructor Details
-
KeyStoreAwareCommand
-
-
Method Details
-
readPassword
protected static SecureString readPassword(org.elasticsearch.cli.Terminal terminal, boolean withVerification) throws org.elasticsearch.cli.UserExceptionReads the keystore password from theTerminal, prompting for verification where applicable and returns it as aSecureString.- Parameters:
terminal- the terminal to use for user inputswithVerification- whether the user should be prompted for password verification- Returns:
- a SecureString with the password the user entered
- Throws:
org.elasticsearch.cli.UserException- If the user is prompted for verification and enters a different password
-
decryptKeyStore
protected static void decryptKeyStore(KeyStoreWrapper keyStore, org.elasticsearch.cli.Terminal terminal) throws org.elasticsearch.cli.UserException, IOExceptionDecrypt thekeyStore, prompting the user to enter the password in theTerminalif it is password protected- Throws:
org.elasticsearch.cli.UserExceptionIOException
-
execute
protected abstract void execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env) throws ExceptionDescription copied from class:EnvironmentAwareCommandExecute the command with the initializedEnvironment.- Specified by:
executein classEnvironmentAwareCommand- Throws:
Exception
-