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
Abstract OTP builder
- Author:
- Bastiaan Jansen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HMACAlgorithmHashing algorithm used to generate code, defaults to SHA1static final HMACAlgorithmDefault value for HMAC Algorithmstatic final intDefault value for password lengthprotected intNumber of digits for generated code in range 6...8, defaults to 6protected byte[]Secret key used to generate the code, this should be a base32 string -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Gbuild()abstract Bintbyte[]withAlgorithm(HMACAlgorithm algorithm) Change hashing algorithmwithPasswordLength(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:
-
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
-