当前位置: 首页>>代码示例>>Python>>正文


Python HmacTokenClass.checkOtp方法代码示例

本文整理汇总了Python中linotp.lib.tokens.hmactoken.HmacTokenClass.checkOtp方法的典型用法代码示例。如果您正苦于以下问题:Python HmacTokenClass.checkOtp方法的具体用法?Python HmacTokenClass.checkOtp怎么用?Python HmacTokenClass.checkOtp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在linotp.lib.tokens.hmactoken.HmacTokenClass的用法示例。


在下文中一共展示了HmacTokenClass.checkOtp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: checkOtp

# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import checkOtp [as 别名]
    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
开发者ID:jimmytuc,项目名称:LinOTP,代码行数:56,代码来源:smstoken.py

示例2: checkOtp

# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import checkOtp [as 别名]
    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
开发者ID:xmycroftx,项目名称:LinOTP,代码行数:41,代码来源:smstoken.py


注:本文中的linotp.lib.tokens.hmactoken.HmacTokenClass.checkOtp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。