Package dev.vink.jtotp
Class TOTPGenerator.Builder
java.lang.Object
dev.vink.jtotp.TOTPGenerator.Builder
- Enclosing class:
- TOTPGenerator
Builder class for constructing instances of TOTPGenerator.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns a TOTPGenerator instance.fromOtpUrl
(String otpUrl) Parses an OTP URL and configures the Builder instance.withAlgorithm
(String algorithm) Sets the HMAC algorithm for the TOTP generation.withDigits
(int digits) Sets the number of digits for the TOTP.withPeriod
(int period) Sets the time period for the TOTP generation.withSecret
(String secret) Sets the shared secret for the TOTP generation.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
withSecret
Sets the shared secret for the TOTP generation.- Parameters:
secret
- The shared secret as a Base32-encoded string.- Returns:
- The current Builder instance.
-
withDigits
Sets the number of digits for the TOTP.- Parameters:
digits
- The number of digits for the TOTP.- Returns:
- The current Builder instance.
-
withAlgorithm
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
Sets the time period for the TOTP generation.- Parameters:
period
- The time period in seconds.- Returns:
- The current Builder instance.
-
fromOtpUrl
Parses an OTP URL and configures the Builder instance.- Parameters:
otpUrl
- The OTP URL to parse.- Returns:
- The current Builder instance.
-
build
Builds and returns a TOTPGenerator instance.- Returns:
- A new TOTPGenerator instance.
-