Package io.github.pratiyush.totp
Class TOTP.Builder
java.lang.Object
io.github.pratiyush.totp.TOTP.Builder
- Enclosing class:
TOTP
Builder for creating TOTP instances.
-
Method Summary
Modifier and TypeMethodDescriptionSets the algorithm.build()Builds the TOTP instance.Sets the clock for time-based operations.config(TOTPConfig config) Sets the TOTP configuration.replayGuard(@Nullable ReplayGuard replayGuard) Sets the replay guard.Enables replay protection with default retention.withReplayProtection(Duration retention) Enables replay protection with an in-memory guard.
-
Method Details
-
config
Sets the TOTP configuration.- Parameters:
config- the configuration- Returns:
- this builder
-
algorithm
Sets the algorithm.- Parameters:
algorithm- the algorithm- Returns:
- this builder
-
clock
Sets the clock for time-based operations.- Parameters:
clock- the clock to use- Returns:
- this builder
-
replayGuard
Sets the replay guard.- Parameters:
replayGuard- the replay guard (may be null to disable)- Returns:
- this builder
-
withReplayProtection
Enables replay protection with an in-memory guard.- Parameters:
retention- how long to track codes- Returns:
- this builder
-
withReplayProtection
Enables replay protection with default retention.- Returns:
- this builder
-
build
Builds the TOTP instance.- Returns:
- configured TOTP instance
-