Class MfaSetupServiceImpl

java.lang.Object
nl._42.restsecure.autoconfigure.authentication.mfa.MfaSetupServiceImpl
All Implemented Interfaces:
MfaSetupService

public class MfaSetupServiceImpl extends Object implements MfaSetupService
Service which contains logic to set up MFA authentication
  • Constructor Details

    • MfaSetupServiceImpl

      public MfaSetupServiceImpl(dev.samstevens.totp.secret.SecretGenerator secretGenerator, dev.samstevens.totp.qr.QrDataFactory qrDataFactory, dev.samstevens.totp.qr.QrGenerator qrGenerator, String issuer)
  • Method Details

    • generateSecret

      public String generateSecret()
      Generates a new MFA secret The secret is to be stored in a secure way for the given user.
      Specified by:
      generateSecret in interface MfaSetupService
      Returns:
      Secret key to generate a QR code and to validate MFA authentication codes.
    • generateQrCode

      public String generateQrCode(String secret, String label) throws MfaException
      Generates a new MFA QR code
      Specified by:
      generateQrCode in interface MfaSetupService
      Parameters:
      secret - Secret key of the user
      label - Label to show in the MFA app. This must be something related to the user (e.g. username, email address).
      Returns:
      A base64-encoded DATA URI of the QR code. This can for example be used in a HTML img element.
      Throws:
      MfaException - If the QR code cannot be generated.