Class Secrets
java.lang.Object
com.codename1.secrets.Secrets
A simple, secure-by-default key/value store for app secrets (auth tokens,
API keys, refresh tokens, anything you must not keep in
Preferences or Storage as
plaintext).
On a device with a platform keychain wired in (iOS Keychain Services,
Android Keystore) the values are protected by the OS secure enclave; if no
hardware store is registered, Secrets falls back to AES-encrypted
storage so a value is never written in the clear. Either way the developer
uses the same four calls:
Secrets.set("auth.token", token);
String token = Secrets.get("auth.token");
if (Secrets.contains("auth.token")) { ... }
Secrets.delete("auth.token");
isHardwareBacked() reports whether the active store is the OS
keychain (vs the software fallback). A platform port or cn1lib installs a
hardware store with setStore(SecretsStore) during initialisation;
see SecretsStore.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanWhether a secret is stored underkey.static voidRemove the secret stored underkey(no-op if absent).static StringThe secret underkey, ornullif absent.static StringThe secret underkey, ordefaultValueif absent.static booleanWhether the active store is the OS keychain (vs the AES software fallback).keys()Keys of all stored secrets (never the values).static voidStore (or replace)valueunderkey.static voidInstall the backing store (called by a platform port / keychain cn1lib at init).
-
Method Details
-
setStore
Install the backing store (called by a platform port / keychain cn1lib at init). -
set
-
get
-
get
-
contains
Whether a secret is stored underkey. -
delete
Remove the secret stored underkey(no-op if absent). -
keys
-
isHardwareBacked
public static boolean isHardwareBacked()Whether the active store is the OS keychain (vs the AES software fallback).
-