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
Modifier and TypeFieldDescriptionstatic int
Arbitrarily chosen maximum passphrase lengthFields inherited from class org.elasticsearch.cli.Command
description, parser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
decryptKeyStore(KeyStoreWrapper keyStore, org.elasticsearch.cli.Terminal terminal)
Decrypt thekeyStore
, prompting the user to enter the password in theTerminal
if it is password protectedprotected abstract void
execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env)
Execute the command with the initializedEnvironment
.protected static SecureString
readPassword(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, execute
Methods inherited from class org.elasticsearch.cli.Command
addShutdownHook, close, exit, main, printAdditionalHelp, printUserException
-
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 theTerminal
if it is password protected- Throws:
org.elasticsearch.cli.UserException
IOException
-
execute
protected abstract void execute(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env) throws ExceptionDescription copied from class:EnvironmentAwareCommand
Execute the command with the initializedEnvironment
.- Specified by:
execute
in classEnvironmentAwareCommand
- Throws:
Exception
-