Interface SecretsStore


public interface SecretsStore

The pluggable backend behind Secrets. A platform port or cn1lib registers a hardware-backed implementation (iOS Keychain Services, Android Keystore / EncryptedSharedPreferences, Windows DPAPI, macOS Keychain) via Secrets.setStore(SecretsStore) so secrets are protected by the operating system's secure enclave. When none is registered, Secrets falls back to DefaultSecretsStore (AES-encrypted at rest in Storage), which is secure-by-default but software-only.

Implementations must treat keys and values as opaque UTF-8 strings and must never log or transmit plaintext values.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether a secret is stored under key.
    void
    Remove the secret stored under key (no-op if absent).
    get(String key)
    Return the secret stored under key, or null if absent.
    boolean
    Whether this store is backed by the device's hardware/OS keychain (true) rather than the software AES-at-rest fallback (false).
    The keys of every stored secret (never the values).
    void
    set(String key, String value)
    Store (or replace) the secret value under key.
  • Method Details

    • set

      void set(String key, String value)
      Store (or replace) the secret value under key.
    • get

      String get(String key)
      Return the secret stored under key, or null if absent.
    • contains

      boolean contains(String key)
      Whether a secret is stored under key.
    • delete

      void delete(String key)
      Remove the secret stored under key (no-op if absent).
    • keys

      List<String> keys()
      The keys of every stored secret (never the values).
    • isHardwareBacked

      boolean isHardwareBacked()
      Whether this store is backed by the device's hardware/OS keychain (true) rather than the software AES-at-rest fallback (false). Lets an app decide whether to store especially sensitive material.