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.IOException
public boolean isLoaded()
SecureSettings
isLoaded
in interface SecureSettings
public boolean hasPassword()
decrypt(char[])
requires a non-empty password.public void decrypt(char[] password) throws java.security.GeneralSecurityException, java.io.IOException
java.security.GeneralSecurityException
java.io.IOException
public java.util.Set<java.lang.String> getSettingNames()
SecureSettings
getSettingNames
in interface SecureSettings
public SecureString getString(java.lang.String setting) throws java.security.GeneralSecurityException
SecureSettings
SecureString
should be closed once it is used.getString
in interface SecureSettings
java.security.GeneralSecurityException
public java.io.InputStream getFile(java.lang.String setting) throws java.security.GeneralSecurityException
SecureSettings
InputStream
should be closed once it is used.getFile
in interface SecureSettings
java.security.GeneralSecurityException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface SecureSettings
java.io.IOException