Class TotpService

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    public class TotpService
    extends ServiceConfig
    Manage application accesses
    • Constructor Detail

      • TotpService

        public TotpService​(dev.samstevens.totp.secret.SecretGenerator secretGenerator,
                           dev.samstevens.totp.qr.QrDataFactory qrDataFactory,
                           dev.samstevens.totp.qr.QrGenerator qrGenerator,
                           dev.samstevens.totp.code.CodeVerifier codeVerifier)
        Autowired constructor
        Parameters:
        secretGenerator - Secret generator
        qrDataFactory - QR Data factory
        qrGenerator - QR Code generator
        codeVerifier - TOTP Code verifier
    • Method Detail

      • getQRCode

        public byte[] getQRCode()
                         throws dev.samstevens.totp.exceptions.QrGenerationException
        Retrieve QR Code in PNG format as String
        Returns:
        QR Code as string
        Throws:
        dev.samstevens.totp.exceptions.QrGenerationException
      • update2faStatus

        public ServiceData update2faStatus​(Integer enabled)
        Update 2fa status
        Returns:
        Service data
      • verify2faCode

        public boolean verify2faCode​(String code)
        Verify if code is valid
        Parameters:
        code - Code to check
        Returns:
        Code is valid or not