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:
TOTPGenerator
-
Field Summary
Fields Modifier and Type Field Description static java.time.DurationDEFAULT_PERIODDefault 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 Constructor Description Builder(byte[] secret)Constructs a TOTPGenerator builder -
Method Summary
Modifier and Type Method Description TOTPGeneratorbuild()Build the generator with specified optionsstatic TOTPGeneratorfromOTPAuthURI(URI uri)Build a TOTPGenerator from an OTPAuth URITOTPGenerator.BuildergetBuilder()java.time.DurationgetPeriod()static TOTPGeneratorwithDefaultValues(byte[] secret)Create a TOTPGenerator with default valuesTOTPGenerator.BuilderwithPeriod(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
-