Reference

Saving passwords and tokens

Store secrets in the Windows Credential Manager or the Linux Secret Service with the optional jolt-credentials module.

jolt-credentials is an optional module (since 0.2.1) that keeps secrets in the operating system's keystore. It needs no window and has no dependency on jolt-core.

Usage

CredentialStore store = CredentialStore.open("com.example.mail");
store.put("alice@example.com", password);
Optional<String> saved = store.get("alice@example.com");
store.delete("alice@example.com");

Add io.github.b077as:jolt-credentials:0.3.1 to your dependencies.

Platforms

  • Windows: the Credential Manager, with secrets up to 2560 bytes in UTF-8.
  • Linux: the Secret Service through libsecret (libsecret-1-0), which needs a running, unlocked keyring.

open throws CredentialStoreUnavailableException when there is no keystore, so catch it and fall back, for example to an encrypted vault behind a master password. Call the store off the UI thread: it can block while the user unlocks the keyring.