Package io.antmedia.security
Class TOTPGenerator
java.lang.Object
io.antmedia.security.TOTPGenerator
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final long[]
protected static org.slf4j.Logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
generateTOTP
(byte[] secretBytes, int duration, int codeDigits, String crypto) static String
generateTOTPWithTimeConstant
(byte[] secretBytes, int codeDigits, String crypto, long timeConstant) This method generates a TOTP value for the given set of parameters.static String
getSecretCodeForNotRecordedSubscriberId
(String subscriberId, String streamId, String type, String secretFromSettings) This generated B32 Secret code on the fly for the subscriberId that is not recorded in the databaseprivate static byte[]
This method uses the JCE to provide the crypto algorithm.
-
Field Details
-
logger
protected static org.slf4j.Logger logger -
DIGITS_POWER
private static final long[] DIGITS_POWER
-
-
Constructor Details
-
TOTPGenerator
public TOTPGenerator()
-
-
Method Details
-
hmac_sha
This method uses the JCE to provide the crypto algorithm. HMAC computes a Hashed Message Authentication Code with the crypto hash algorithm as a parameter.- Parameters:
crypto
- : the crypto algorithm (HmacSHA1, HmacSHA256, HmacSHA512)keyBytes
- : the bytes to use for the HMAC keytext
- : the message or text to be authenticated
-
getSecretCodeForNotRecordedSubscriberId
public static String getSecretCodeForNotRecordedSubscriberId(String subscriberId, String streamId, String type, String secretFromSettings) This generated B32 Secret code on the fly for the subscriberId that is not recorded in the database- Parameters:
subscriberId
-streamId
-secretFromSettings
-- Returns:
-
generateTOTPWithTimeConstant
public static String generateTOTPWithTimeConstant(byte[] secretBytes, int codeDigits, String crypto, long timeConstant) This method generates a TOTP value for the given set of parameters.- Parameters:
key
- : the shared secret, HEX encodedtime
- : a value that reflects a timereturnDigits
- : number of digits to returncrypto
- : the crypto function to use (HmacSHA1 | HmacSHA256 | HmacSHA512)
-
generateTOTP
-