Class InMemoryTotpStore
java.lang.Object
com.revetsec.totp.InMemoryTotpStore
- All Implemented Interfaces:
TotpStore
@ThreadSafe
@CheckReturnValue
public final class InMemoryTotpStore
extends Object
implements TotpStore
Explicit bounded, volatile, single-process TOTP demonstration store. Restart loses factors,
recovery consumption, replay marks and every recovery/clock fence. Never use it as an automatic
fallback, as authoritative storage for established accounts or across independent processes.
No record is evicted or expired. A configured namespace begins NEW and activates only through
an atomic initialization write. Fresh recovery epochs retain old records and permanently fence
old writers; this process-local history is not a substitute for an external durable controller.
The first operational call establishes this store's own volatile UTC projection and metadata. The authenticator's worker Clock is not its time source. The store checks its elapsed projection against a fresh host UTC sample on each operation. A discontinuity starts a new clock generation, fencing work from the old generation; after a backward step the store remains unavailable until host UTC reaches the last published point. This is a local demonstration assertion, not external UTC, restore, device-durability or suspend/rate qualification.
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCaller-thread configuration for explicit volatile storage. -
Method Summary
Modifier and TypeMethodDescriptioncompareAndCommit(@NonNull TotpStoreWrite write, @NonNull Duration remainingBudget) Atomically compares current admission, epoch and all snapshot predicates, then validates fresh store-authoritative time after every wait, including for condition-only writes.provisionRecoveryEpoch(@NonNull String recoveryEpoch, @NonNull Duration remainingBudget) Provisions and fences to a fresh epoch in this demonstration store.Reads exactly the requested nonempty bounded scope at one authoritative snapshot point, checking the active epoch and operational admission in the same transaction.toString()Redacts stored records and recovery configuration.withNamespace(@NonNull String credentialNamespace, @NonNull String recoveryEpoch) Starts configuration for one explicit volatile namespace and fresh recovery epoch.
-
Method Details
-
withNamespace
public static @NonNull InMemoryTotpStore.Builder withNamespace(@NonNull String credentialNamespace, @NonNull String recoveryEpoch) Starts configuration for one explicit volatile namespace and fresh recovery epoch.- Parameters:
credentialNamespace- the visible ASCII namespacerecoveryEpoch- the never-reused recovery epoch- Returns:
- a caller-thread builder
- Since:
- 1.0.0
-
provisionRecoveryEpoch
public @NonNull TotpStoreCommitResult provisionRecoveryEpoch(@NonNull String recoveryEpoch, @NonNull Duration remainingBudget) Provisions and fences to a fresh epoch in this demonstration store. The application must close admission and drain operations before calling it. Existing records remain retained and count against capacity. An epoch previously used by this store can never be selected again. The time projection and authority identity continue; only data recovery admission changes. This cannot repair lost clock continuity or establish shared-store recovery after restart.- Parameters:
recoveryEpoch- the fresh never-reused epochremainingBudget- remaining positive administration budget- Returns:
- factual COMMITTED, or CAPACITY_REFUSED/UNAVAILABLE before mutation
- Since:
- 1.0.0
-
read
public @NonNull TotpStoreReadResult read(@NonNull Set<@NonNull TotpStoreKey> keys, @NonNull Duration remainingBudget) Description copied from interface:TotpStoreReads exactly the requested nonempty bounded scope at one authoritative snapshot point, checking the active epoch and operational admission in the same transaction. The entries and fresh admitted time or time-only unavailability form one coherent observation. Explicitly represent every absence; no cleanup, quota update or floor write belongs to a read. -
compareAndCommit
public @NonNull TotpStoreCommitReceipt compareAndCommit(@NonNull TotpStoreWrite write, @NonNull Duration remainingBudget) Description copied from interface:TotpStoreAtomically compares current admission, epoch and all snapshot predicates, then validates fresh store-authoritative time after every wait, including for condition-only writes.- Specified by:
compareAndCommitin interfaceTotpStore- Parameters:
write- the exact predicates and complete change setremainingBudget- remaining positive operation budget- Returns:
- the factual contextual receipt, with required validation timing for COMMITTED
-
toString
-