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

public abstract class KeyStoreAwareCommand extends EnvironmentAwareCommand
An EnvironmentAwareCommand that needs to access the elasticsearch keystore, possibly decrypting it if it is password protected.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    Arbitrarily chosen maximum passphrase length

    Fields inherited from class org.elasticsearch.cli.Command

    description, parser
  • Constructor Summary

    Constructors
    Constructor
    Description
    KeyStoreAwareCommand​(String description)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static void
    decryptKeyStore​(KeyStoreWrapper keyStore, org.elasticsearch.cli.Terminal terminal)
    Decrypt the keyStore, prompting the user to enter the password in the Terminal if it is password protected
    protected abstract void
    execute​(org.elasticsearch.cli.Terminal terminal, joptsimple.OptionSet options, Environment env)
    Execute the command with the initialized Environment.
    protected static SecureString
    readPassword​(org.elasticsearch.cli.Terminal terminal, boolean withVerification)
    Reads the keystore password from the Terminal, prompting for verification where applicable and returns it as a SecureString.

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_PASSPHRASE_LENGTH

      public static final int MAX_PASSPHRASE_LENGTH
      Arbitrarily chosen maximum passphrase length
      See Also:
      Constant Field Values
  • Constructor Details

    • KeyStoreAwareCommand

      public KeyStoreAwareCommand(String description)
  • Method Details

    • readPassword

      protected static SecureString readPassword(org.elasticsearch.cli.Terminal terminal, boolean withVerification) throws org.elasticsearch.cli.UserException
      Reads the keystore password from the Terminal, prompting for verification where applicable and returns it as a SecureString.
      Parameters:
      terminal - the terminal to use for user inputs
      withVerification - 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, IOException
      Decrypt the keyStore, prompting the user to enter the password in the Terminal 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 Exception
      Description copied from class: EnvironmentAwareCommand
      Execute the command with the initialized Environment.
      Specified by:
      execute in class EnvironmentAwareCommand
      Throws:
      Exception