Class TwoFA

java.lang.Object
ch.autumo.beetroot.utils.web.TwoFA

public class TwoFA extends Object
2-FA Google Authenticator.
  • Constructor Details

    • TwoFA

      public TwoFA()
  • Method Details

    • createSecretUserKey

      public static String createSecretUserKey()
      Generate a secret user key with specific length. Note: Only initially for every user once!
      Returns:
      secret user key
    • createSecretUserKey

      public static String createSecretUserKey(int len)
      Generate a secret user key with specific length. Note: Only initially for every user once!
      Parameters:
      len - length
      Returns:
      secret user key
    • create6DigitTOTPCode

      public static String create6DigitTOTPCode(String secretUserKey)
      Create 5-digit TOTP (time-based one-time password) code for a user secret key.
      Parameters:
      secretUserKey - secret user key
      Returns:
      code
    • getGoogleAuthenticatorBarCode

      public static String getGoogleAuthenticatorBarCode(String secretUserKey, String email) throws UtilsException
      Create Google Authenticator bar code.
      Parameters:
      secretUserKey - secret user key
      email - email of user
      Returns:
      bar code
      Throws:
      UtilsException - utilities exception
    • createQRCode

      public static String createQRCode(String barCodeData, int height, int width) throws UtilsException
      Create QR code.
      Parameters:
      barCodeData - Google authenticator bar code.
      height - height of QR code image
      width - width of QR code image
      Returns:
      path to QR code image file
      Throws:
      UtilsException - utilities exception