Class TOTPGenerator.Builder

java.lang.Object
dev.vink.jtotp.TOTPGenerator.Builder
Enclosing class:
TOTPGenerator

public static class TOTPGenerator.Builder extends Object
Builder class for constructing instances of TOTPGenerator.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • withSecret

      public TOTPGenerator.Builder withSecret(String secret)
      Sets the shared secret for the TOTP generation.
      Parameters:
      secret - The shared secret as a Base32-encoded string.
      Returns:
      The current Builder instance.
    • withDigits

      public TOTPGenerator.Builder withDigits(int digits)
      Sets the number of digits for the TOTP.
      Parameters:
      digits - The number of digits for the TOTP.
      Returns:
      The current Builder instance.
    • withAlgorithm

      public TOTPGenerator.Builder withAlgorithm(String algorithm)
      Sets the HMAC algorithm for the TOTP generation.
      Parameters:
      algorithm - The algorithm to use (e.g., HmacSHA1, HmacSHA256, HmacSHA512).
      Returns:
      The current Builder instance.
    • withPeriod

      public TOTPGenerator.Builder withPeriod(int period)
      Sets the time period for the TOTP generation.
      Parameters:
      period - The time period in seconds.
      Returns:
      The current Builder instance.
    • fromOtpUrl

      public TOTPGenerator.Builder fromOtpUrl(String otpUrl)
      Parses an OTP URL and configures the Builder instance.
      Parameters:
      otpUrl - The OTP URL to parse.
      Returns:
      The current Builder instance.
    • build

      public TOTPGenerator build()
      Builds and returns a TOTPGenerator instance.
      Returns:
      A new TOTPGenerator instance.