Class TOTPGenerator

java.lang.Object
io.antmedia.security.TOTPGenerator

public class TOTPGenerator extends Object
  • 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

      private static byte[] hmac_sha(String crypto, byte[] keyBytes, byte[] text)
      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 key
      text - : 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 encoded
      time - : a value that reflects a time
      returnDigits - : number of digits to return
      crypto - : the crypto function to use (HmacSHA1 | HmacSHA256 | HmacSHA512)
    • generateTOTP

      public static String generateTOTP(byte[] secretBytes, int duration, int codeDigits, String crypto)