java.lang.Object
net.morimekta.config.SecretsManager
- All Implemented Interfaces:
Closeable,AutoCloseable
A class managing secrets as read from files in a single directory.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA deserializer for secrets manager to make it easy to include the manager in a standard jackson-parsed config file (JSON or YAML).static classSimple configuration of the secrets manager as an object. -
Constructor Summary
ConstructorsConstructorDescriptionSecretsManager(Path secretsDir) Create a secrets manager getting secrets from the specified directory.SecretsManager(Path secretsDir, net.morimekta.file.FileWatcher fileWatcher) Create a secrets manager getting secrets from the specified directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanCheck if secret with given name exists.Get a named secret from the secret store.net.morimekta.collect.util.BinarygetAsBinary(String name) Get a named secret from the secret store as a binary.byte[]getAsBytes(String name) Get a named secret from the secret store as a byte array.Get the path to a named secret from the secret store.getAsString(String name) Get a named secret from the secret store as a string.toString()
-
Constructor Details
-
SecretsManager
Create a secrets manager getting secrets from the specified directory.- Parameters:
secretsDir- The secrets directory. All non-hidden files in the- Throws:
IOException- If the path does not point to an existing directory.
-
SecretsManager
public SecretsManager(Path secretsDir, net.morimekta.file.FileWatcher fileWatcher) throws IOException Create a secrets manager getting secrets from the specified directory.- Parameters:
secretsDir- The secrets' directory. All non-hidden files in thefileWatcher- File watcher used to get file events.- Throws:
IOException- If the path does not point to an existing directory.
-
-
Method Details
-
getSecretsPath
- Returns:
- Get the configured secrets directory path.
-
exists
Check if secret with given name exists.- Parameters:
name- The secret name.- Returns:
- If the secret exists.
-
getKnownSecrets
- Returns:
- Get a list a set of known secret names.
-
getAsPath
Get the path to a named secret from the secret store.- Parameters:
name- The secret name.- Returns:
- The secret file path.
-
getAsString
Get a named secret from the secret store as a string.- Parameters:
name- The secret name.- Returns:
- The secret value as a string.
-
getAsBytes
Get a named secret from the secret store as a byte array.- Parameters:
name- The secret name.- Returns:
- The secret value as a string.
-
getAsBinary
Get a named secret from the secret store as a binary.- Parameters:
name- The secret name.- Returns:
- The secret value as a binary.
-
get
Get a named secret from the secret store.- Parameters:
name- The secret name.- Returns:
- The loaded secret.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-