Package com.bastiaanjansen.otp
Class TOTPGenerator.Builder
java.lang.Object
com.bastiaanjansen.otp.OTPGenerator.Builder<TOTPGenerator.Builder,TOTPGenerator>
com.bastiaanjansen.otp.TOTPGenerator.Builder
- Enclosing class:
- TOTPGenerator
public static class TOTPGenerator.Builder
extends OTPGenerator.Builder<TOTPGenerator.Builder,TOTPGenerator>
- Author:
- Bastiaan Jansen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final java.time.DurationDefault time interval for a time-based one-time passwordFields inherited from class com.bastiaanjansen.otp.OTPGenerator.Builder
algorithm, DEFAULT_HMAC_ALGORITHM, DEFAULT_PASSWORD_LENGTH, passwordLength, secret -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the generator with specified optionsstatic TOTPGeneratorfromOTPAuthURI(URI uri) Build a TOTPGenerator from an OTPAuth URIjava.time.Durationstatic TOTPGeneratorwithDefaultValues(byte[] secret) Create a TOTPGenerator with default valueswithPeriod(java.time.Duration period) Change periodMethods inherited from class com.bastiaanjansen.otp.OTPGenerator.Builder
getAlgorithm, getPasswordLength, getSecret, withAlgorithm, withPasswordLength
-
Field Details
-
DEFAULT_PERIOD
public static final java.time.Duration DEFAULT_PERIODDefault time interval for a time-based one-time password
-
-
Constructor Details
-
Builder
public Builder(byte[] secret) Constructs a TOTPGenerator builder- Parameters:
secret- used to generate hash
-
-
Method Details
-
withPeriod
Change period- Parameters:
period- time interval between new codes- Returns:
- builder
-
getPeriod
public java.time.Duration getPeriod() -
build
Build the generator with specified options- Specified by:
buildin classOTPGenerator.Builder<TOTPGenerator.Builder,TOTPGenerator> - Returns:
- TOTPGenerator
-
getBuilder
- Specified by:
getBuilderin classOTPGenerator.Builder<TOTPGenerator.Builder,TOTPGenerator>
-
fromOTPAuthURI
Build a TOTPGenerator from an OTPAuth URI- Parameters:
uri- OTPAuth URI- Returns:
- TOTPGenerator
- Throws:
URISyntaxException- when URI cannot be parsed
-
withDefaultValues
Create a TOTPGenerator with default values- Parameters:
secret- used to generate hash- Returns:
- a TOTPGenerator with default values
-