Class SecretsTool
SECRETS-STORE-DESIGN.md section 10, build order SK-4, decision P-16 (a)): what an operator of a production server and a build script use to fill, read and check the store that SecretsStore keeps. It runs the same store class as the server, through SecretsLifecycle.openServerStore(Path, PropFactory, long, boolean), so the file it writes is the file the server reads.The store file is --store <file> when given, else the system property "iizi.secrets.file", else <user.home>/.iizi-secrets/iizi-secrets.xml (SecretsStore.defaultFile()).
Commands.
set <key> [--kind string|password|pkcs12] [--dbconf <directory>]- stores a value read from standard input, never from the command line: piped, with one trailing line ending removed for a text kind, or typed twice without echo when standard input is a terminal. The prompt says what the key is for (describeKey(String, String)): for adbconf.<name>/passwordkey the database role and the URL of thedbconf.propertiesin the directory--dbconfnames, which must name the key as itspasswordSecret(MDV-D-30: the MLS rehearsal's operator was asked for a "Value of dbconf.mls/password" and could not tell which password that was). A new key needs--kind; an existing one keeps its kind unless--kindnames another. Written at once, owner-only and atomically, by the store.get <key> [--tty]- writes the value to standard output, exactly its UTF-8 bytes (the bytes of a PKCS#12), the only command that ever prints a value; refused when standard output is a terminal unless--ttyis given.remove <key>(orrm) - removes a key.list [<context>...]- the keys, one per line, never a value.export <file> [<context>...]- writes the entries, or those of the contexts, to a new owner-only store file.import <file> [<context>...]- merges the entries of another store file, or those of the contexts, into the store in one write; an imported key replaces the store's.check <file> [--context <context>]- loads a configuration file and lists, one per line, the keys of its secret-marked members that the store lacks (through the contexts of CC-SECRETS-SK3-CONTEXTS);--contextgives the context a.iiziPushfile takes from its application at run time.
Standard output carries data only: the value of get, the keys of list, the missing keys of check. Everything else - confirmations, errors and the WARNING and SEVERE lines of the logger, which a plain JVM would print on standard output - goes to standard error. No value is ever written to standard error, a log line or an exception text, and none is read from the command line, so none can appear in a process list or a shell history.
Exit codes: 0 done; 1 a usage error; 2 the store or a file could not be opened, read or written; 3 a key that is not there (get, remove), or a check that found a missing key, a kind mismatch or a member without a context; 4 a value refused to a terminal.
Launched by iiziServer/bin/iizi-secrets.bat and iizi-secrets.sh, and by Get-IiziSecret of BuildUtil/mindus.psm1.
- Author:
- Christopher Mindus
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe exit code of a store or file that could not be opened, read or written: 2.static final intThe exit code of a key that is not there, or of a check that found a problem: 3.static final intThe exit code of a command that was done: 0.static final intThe exit code of a value refused to a terminal: 4.static final intThe exit code of a usage error: 1.Constructor Summary
ConstructorsConstructorDescriptionSecretsTool(PropFactory factory, Path defaultStore, InputStream in, OutputStream out, PrintStream err, boolean stdinTerminal, boolean stdoutTerminal) Constructor.Method Summary
Field Details
EXIT_OK
public static final int EXIT_OKThe exit code of a command that was done: 0.- See Also:
EXIT_USAGE
public static final int EXIT_USAGEThe exit code of a usage error: 1.- See Also:
EXIT_FAILED
public static final int EXIT_FAILEDThe exit code of a store or file that could not be opened, read or written: 2.- See Also:
EXIT_MISSING
public static final int EXIT_MISSINGThe exit code of a key that is not there, or of a check that found a problem: 3.- See Also:
EXIT_REFUSED
public static final int EXIT_REFUSEDThe exit code of a value refused to a terminal: 4.- See Also:
Constructor Details
SecretsTool
public SecretsTool(PropFactory factory, Path defaultStore, InputStream in, OutputStream out, PrintStream err, boolean stdinTerminal, boolean stdoutTerminal) Constructor.main(String[])builds one over the process's own streams; a test or another program may give its own.- Parameters:
factory- The SERVER property factory, its definitions loaded.defaultStore- The store file when--storeis not given, normallySecretsStore.defaultFile().in- Standard input.out- Standard output, for data only.err- Standard error.stdinTerminal- true when standard input is a terminal:setthen reads the value from the console without echo.stdoutTerminal- true when standard output is a terminal:getthen refuses without--tty.
Method Details
main
Runs the tool in its own process and exits with its exit code. Standard output and standard error are taken from the file descriptors before the logger replacesSystem.outandSystem.err; the logger's WARNING and SEVERE lines go to standard error, nothing below.- Parameters:
args- The command line.
run
Runs one command. The store is opened for the command and disposed of afterwards.- Parameters:
args- The command line.- Returns:
- The exit code.