java.io.Closeable, java.lang.AutoCloseable, SecureSettingspublic class KeyStoreWrapper extends java.lang.Object implements SecureSettings
load(Path). Then call
decrypt(char[]) with the keystore password, or an empty char array if
hasPassword() is false. Loading and decrypting should happen
in a single thread. Once decrypted, keys may be read with the wrapper in
multiple threads.| Modifier and Type | Field | Description |
|---|---|---|
static Setting<SecureString> |
SEED_SETTING |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
addBootstrapSeed(KeyStoreWrapper wrapper) |
Add the bootstrap seed setting, which may be used as a unique, secure, random value by the node
|
void |
close() |
|
static KeyStoreWrapper |
create(char[] password) |
Constructs a new keystore with the given password.
|
void |
decrypt(char[] password) |
Decrypts the underlying java keystore.
|
java.io.InputStream |
getFile(java.lang.String setting) |
Return a file setting.
|
java.util.Set<java.lang.String> |
getSettingNames() |
Returns the names of all secure settings available.
|
SecureString |
getString(java.lang.String setting) |
Return a string setting.
|
boolean |
hasPassword() |
Return true iff calling
decrypt(char[]) requires a non-empty password. |
boolean |
isLoaded() |
Returns true iff the settings are loaded and retrievable.
|
static java.nio.file.Path |
keystorePath(java.nio.file.Path configDir) |
Returns a path representing the ES keystore in the given config dir.
|
static KeyStoreWrapper |
load(java.nio.file.Path configDir) |
Loads information about the Elasticsearch keystore from the provided config directory.
|
void |
save(java.nio.file.Path configDir) |
Write the keystore to the given config directory.
|
static void |
upgrade(KeyStoreWrapper wrapper,
java.nio.file.Path configDir) |
Upgrades the format of the keystore, if necessary.
|
static void |
validateSettingName(java.lang.String setting) |
Ensure the given setting name is allowed.
|
public static final Setting<SecureString> SEED_SETTING
public static java.nio.file.Path keystorePath(java.nio.file.Path configDir)
public static KeyStoreWrapper create(char[] password) throws java.lang.Exception
java.lang.Exceptionpublic static void addBootstrapSeed(KeyStoreWrapper wrapper) throws java.security.GeneralSecurityException
java.security.GeneralSecurityExceptionpublic static KeyStoreWrapper load(java.nio.file.Path configDir) throws java.io.IOException
decrypt(char[]) must be called before reading or writing any entries.
Returns null if no keystore exists.java.io.IOExceptionpublic static void upgrade(KeyStoreWrapper wrapper, java.nio.file.Path configDir) throws java.lang.Exception
java.lang.Exceptionpublic boolean isLoaded()
SecureSettingsisLoaded in interface SecureSettingspublic boolean hasPassword()
decrypt(char[]) requires a non-empty password.public void decrypt(char[] password)
throws java.security.GeneralSecurityException,
java.io.IOException
java.security.GeneralSecurityExceptionjava.io.IOExceptionpublic void save(java.nio.file.Path configDir)
throws java.lang.Exception
java.lang.Exceptionpublic java.util.Set<java.lang.String> getSettingNames()
SecureSettingsgetSettingNames in interface SecureSettingspublic SecureString getString(java.lang.String setting) throws java.security.GeneralSecurityException
SecureSettingsSecureString should be closed once it is used.getString in interface SecureSettingsjava.security.GeneralSecurityExceptionpublic java.io.InputStream getFile(java.lang.String setting)
throws java.security.GeneralSecurityException
SecureSettingsInputStream should be closed once it is used.getFile in interface SecureSettingsjava.security.GeneralSecurityExceptionpublic static void validateSettingName(java.lang.String setting)
java.lang.IllegalArgumentException - if the setting name is not validpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeableclose in interface SecureSettingsjava.io.IOException