Interface OtpHandler


  • public interface OtpHandler
    Methods for managing single use passwords for confirming specific actions. Not to be confused with passwords with mode = PasswordMode.OTP.
    • Field Detail

      • RESEND_SECONDS

        static final int RESEND_SECONDS
        Seconds to wait before allowing an OTP to be re-sent
        See Also:
        Constant Field Values
    • Method Detail

      • find

        Otp find​(Long id)
        Finds an OTP by id
      • getAvailableSendMediums

        Set<SendMedium> getAvailableSendMediums()
        Returns send mediums available for the logged user
      • getDate

        Date getDate​(OtpType type,
                     OtpOwner owner)
        Returns when the OTP with the given number and type was sent. When not sent, returns null;
      • getMobilePhone

        MobilePhone getMobilePhone​(Otp otp)
        Returns the mobile phone related to the user of the given OTP
      • getSendOtpData

        SendOtpData getSendOtpData()
        Returns data used to send an OTP for the logged user
      • hasAvailableSendMediums

        boolean hasAvailableSendMediums()
        Returns true if the logged user has at least one medium to send to the activation code.
      • remove

        long remove​(OtpType type,
                    OtpOwner owner)
        Removes any existing OTP for the given type and owner
      • sendForAccessClientActivation

        Otp sendForAccessClientActivation​(User user,
                                          MobilePhone mobilePhone)
        Sends an OTP for activating an access client of the given user. When phone is null it is assumed it is sent by email.
      • sendForDeviceActivation

        RequestActivationResult sendForDeviceActivation​(TrustedDevice device,
                                                        MobilePhone phone)
        Sends an OTP for activating a trusted device of the given user. When phone is null it is assumed it is sent by email.
      • sendForPhoneVerification

        Otp sendForPhoneVerification​(MobilePhone phone)
        Sends an OTP for verifying a phone.
      • sendForTotpActivation

        Otp sendForTotpActivation​(BasicUser user,
                                  MobilePhone phone)
        Sends an OTP for activating a new TOTP device. When phone is null, it is sent via email.
      • verify

        Otp verify​(OtpType type,
                   OtpOwner owner,
                   String value)
            throws ValidationException
        Checks for an OTP which matches the given type, owner and value. Adds a before end listener to remove the OTP when running in a READ_WRITE transaction.
        Returns:
        the OTP with the given value (i.e. code), never null
        Throws:
        ValidationException - when an OTP couldn't be found