public 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 | Method and Description |
|---|---|
void |
close() |
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 KeyStoreWrapper |
load(java.nio.file.Path configDir)
Loads information about the Elasticsearch keystore from the provided config directory.
|
public 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 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 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 void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface SecureSettingsjava.io.IOException