Package com.bastiaanjansen.otp
Class OTPGenerator.Builder<B,G>
java.lang.Object
com.bastiaanjansen.otp.OTPGenerator.Builder<B,G>
- Type Parameters:
B- concrete builder class
- Direct Known Subclasses:
HOTPGenerator.Builder,TOTPGenerator.Builder
- Enclosing class:
- OTPGenerator
public abstract static class OTPGenerator.Builder<B,G> extends Object
Abstract OTP builder
- Author:
- Bastiaan Jansen
-
Field Summary
Fields Modifier and Type Field Description protected HMACAlgorithmalgorithmHashing algorithm used to generate code, defaults to SHA1static HMACAlgorithmDEFAULT_HMAC_ALGORITHMDefault value for HMAC Algorithmstatic intDEFAULT_PASSWORD_LENGTHDefault value for password lengthprotected intpasswordLengthNumber of digits for generated code in range 6...8, defaults to 6protected byte[]secretSecret key used to generate the code, this should be a base32 string -
Constructor Summary
Constructors Constructor Description Builder(byte[] secret) -
Method Summary
Modifier and Type Method Description abstract Gbuild()HMACAlgorithmgetAlgorithm()abstract BgetBuilder()intgetPasswordLength()byte[]getSecret()BwithAlgorithm(HMACAlgorithm algorithm)Change hashing algorithmBwithPasswordLength(int passwordLength)Change password length of code
-
Field Details
-
passwordLength
protected int passwordLengthNumber of digits for generated code in range 6...8, defaults to 6 -
algorithm
Hashing algorithm used to generate code, defaults to SHA1 -
secret
protected byte[] secretSecret key used to generate the code, this should be a base32 string -
DEFAULT_PASSWORD_LENGTH
public static final int DEFAULT_PASSWORD_LENGTHDefault value for password length- See Also:
- Constant Field Values
-
DEFAULT_HMAC_ALGORITHM
Default value for HMAC Algorithm
-
-
Constructor Details
-
Builder
public Builder(byte[] secret)
-
-
Method Details
-
withPasswordLength
Change password length of code- Parameters:
passwordLength- number of digits for generated code in range 6...8- Returns:
- concrete builder
-
withAlgorithm
Change hashing algorithm- Parameters:
algorithm- HMAC hashing algorithm- Returns:
- concrete builder
-
getSecret
public byte[] getSecret() -
getPasswordLength
public int getPasswordLength() -
getAlgorithm
-
getBuilder
-
build
-