def checkOtp(self, anOtpVal, counter, window, options=None): ''' checkOtp - check the otpval of a token against a given counter in the + window range :param passw: the to be verified passw/pin :type passw: string :return: counter if found, -1 if not found :rtype: int ''' log.debug("[checkOtp] begin. start to verify the otp value: anOtpVal:" " %r, counter: %r, window: %r, options: %r " % (anOtpVal, counter, window, options)) if not options: options = {} ret = HmacTokenClass.checkOtp(self, anOtpVal, counter, window) if ret != -1: if self.isValid() == False: ret = -1 if ret >= 0: if get_auth_AutoSMSPolicy(): user = None message = "<otp>" realms = self.getRealms() if realms: _sms_ret, message = get_auth_smstext(realm=realms[0]) if 'user' in options: user = options.get('user', None) if user: _sms_ret, message = get_auth_smstext(realm=user.realm) realms = self.getRealms() if 'data' in options or 'message' in options: message = options.get('data', options.get('message', '<otp>')) try: _success, message = self.sendSMS(message=message) except Exception as exx: log.exception(exx) finally: self.incOtpCounter(ret, reset=False) if ret >= 0: msg = "otp verification was successful!" else: msg = "otp verification failed!" log.debug("[checkOtp] end. %s ret: %r" % (msg, ret)) return ret
def checkOtp(self, anOtpVal, counter, window, options=None): ''' checkOtp - check the otpval of a token against a given counter in the + window range :param passw: the to be verified passw/pin :type passw: string :return: counter if found, -1 if not found :rtype: int ''' log.debug("[checkOtp] begin. start to verify the otp value: anOtpVal:" " %r, counter: %r, window: %r, options: %r " % (anOtpVal, counter, window, options)) if not options: options = {} ret = HmacTokenClass.checkOtp(self, anOtpVal, counter, window) if ret != -1: if self.isValid() is False: ret = -1 if ret >= 0: if get_auth_AutoSMSPolicy(): user = None message = "<otp>" realms = self.getRealms() if realms: _sms_ret, message = get_auth_smstext(realm=realms[0]) if 'user' in options: user = options.get('user', None) if user: _sms_ret, message = get_auth_smstext(realm=user.realm) realms = self.getRealms() if 'data' in options or 'message' in options: message = options.get('data', options.get('message', '<otp>')) try: _success, message = self.sendSMS(message=message) except Exception as exx: log.exception(exx) finally: self.incOtpCounter(ret, reset=False) if ret >= 0: msg = "otp verification was successful!" else: msg = "otp verification failed!" log.debug("[checkOtp] end. %s ret: %r" % (msg, ret)) return ret
def checkOtp(self, anOtpVal, counter, window, options=None): ''' checkOtp - check the otpval of a token against a given counter in the + window range :param passw: the to be verified passw/pin :type passw: string :return: counter if found, -1 if not found :rtype: int ''' log.debug( "[checkOtp] begin. start to verify the otp value: anOtpVal:" + " %r, counter: %r, window: %r, options: %r " % (anOtpVal, counter, window, options)) ret = HmacTokenClass.checkOtp(self, anOtpVal, counter, window) if ret != -1: if self.isValid() == False: ret = -1 if ret >= 0: if get_auth_AutoSMSPolicy(): user = None message = "<otp>" if options is not None and type(options) == dict: user = options.get('user', None) if user: sms_ret, message = get_auth_smstext(realm=user.realm) self.incOtpCounter(ret, reset=False) success, message = self.sendSMS(message=message) if ret >= 0: msg = "otp verification was successful!" else: msg = "otp verification failed!" log.debug("[checkOtp] end. %s ret: %r" % (msg, ret)) return ret
def checkOtp(self, anOtpVal, counter, window, options=None): """ checkOtp - check the otpval of a token against a given counter in the + window range :param passw: the to be verified passw/pin :type passw: string :return: counter if found, -1 if not found :rtype: int """ log.debug( "[checkOtp] begin. start to verify the otp value: anOtpVal:" + " %r, counter: %r, window: %r, options: %r " % (anOtpVal, counter, window, options) ) ret = HmacTokenClass.checkOtp(self, anOtpVal, counter, window) if ret != -1: if self.isValid() == False: ret = -1 if ret >= 0: if get_auth_AutoSMSPolicy(): user = None message = "<otp>" if options is not None and type(options) == dict: user = options.get("user", None) if user: sms_ret, message = get_auth_smstext(realm=user.realm) self.incOtpCounter(ret, reset=False) success, message = self.sendSMS(message=message) if ret >= 0: msg = "otp verification was successful!" else: msg = "otp verification failed!" log.debug("[checkOtp] end. %s ret: %r" % (msg, ret)) return ret