Class TotpStoreKey

java.lang.Object
com.revetsec.totp.TotpStoreKey

@Immutable public final class TotpStoreKey extends Object
Canonical, namespace- and recovery-epoch-bound address of permanent TOTP state. Account IDs appear only as domain-separated SHA-256 digests. Constructing an address confers no authority. Storage addresses are sensitive and must not be logged.
Since:
1.0.0
  • Method Details

    • forNamespace

      public static @NonNull TotpStoreKey forNamespace(@NonNull String credentialNamespace, @NonNull String recoveryEpoch)
      Addresses the permanent namespace clock and initialization fence.
      Parameters:
      credentialNamespace - the visible ASCII namespace, from 1 to 128 characters
      recoveryEpoch - the never-reused visible ASCII recovery epoch, from 1 to 128 characters
      Returns:
      the namespace address
      Since:
      1.0.0
    • forAccount

      public static @NonNull TotpStoreKey forAccount(@NonNull String credentialNamespace, @NonNull String recoveryEpoch, @NonNull String accountId)
      Addresses the permanent account aggregate without disclosing its identifier in the address.
      Parameters:
      credentialNamespace - the visible ASCII namespace
      recoveryEpoch - the never-reused recovery epoch
      accountId - the nonempty, well-formed account identifier, at most 1024 UTF-8 bytes
      Returns:
      the account address
      Since:
      1.0.0
    • fromStoredForm

      public static @NonNull TotpStoreKey fromStoredForm(@NonNull String storageKey)
      Parses a bounded canonical persistence address; authenticity is checked when opening its record.
      Parameters:
      storageKey - the exact stored address
      Returns:
      the parsed address
      Since:
      1.0.0
    • getStorageKey

      Returns the exact sensitive persistence address.
      Returns:
      the address; never log it
      Since:
      1.0.0
    • getCredentialNamespace

      Returns the credential namespace.
      Returns:
      the namespace
      Since:
      1.0.0
    • getRecoveryEpoch

      Returns the recovery epoch.
      Returns:
      the epoch
      Since:
      1.0.0
    • getKind

      Returns the permanent record kind.
      Returns:
      the kind
      Since:
      1.0.0
    • equals

      public boolean equals(@Nullable Object other)
      Compares the complete persistence address.
      Overrides:
      equals in class Object
      Since:
      1.0.0
    • hashCode

      public int hashCode()
      Returns the complete address hash.
      Overrides:
      hashCode in class Object
      Since:
      1.0.0
    • toString

      Redacts the address.
      Overrides:
      toString in class Object
      Since:
      1.0.0