Class TOTP.Builder

java.lang.Object
io.github.pratiyush.totp.TOTP.Builder
Enclosing class:
TOTP

public static final class TOTP.Builder extends Object
Builder for creating TOTP instances.
  • Method Details

    • config

      public TOTP.Builder config(TOTPConfig config)
      Sets the TOTP configuration.
      Parameters:
      config - the configuration
      Returns:
      this builder
    • algorithm

      public TOTP.Builder algorithm(Algorithm algorithm)
      Sets the algorithm.
      Parameters:
      algorithm - the algorithm
      Returns:
      this builder
    • clock

      public TOTP.Builder clock(TOTPClock clock)
      Sets the clock for time-based operations.
      Parameters:
      clock - the clock to use
      Returns:
      this builder
    • replayGuard

      public TOTP.Builder replayGuard(@Nullable ReplayGuard replayGuard)
      Sets the replay guard.
      Parameters:
      replayGuard - the replay guard (may be null to disable)
      Returns:
      this builder
    • withReplayProtection

      public TOTP.Builder withReplayProtection(Duration retention)
      Enables replay protection with an in-memory guard.
      Parameters:
      retention - how long to track codes
      Returns:
      this builder
    • withReplayProtection

      public TOTP.Builder withReplayProtection()
      Enables replay protection with default retention.
      Returns:
      this builder
    • build

      public TOTP build()
      Builds the TOTP instance.
      Returns:
      configured TOTP instance