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


Python PolicyClass.get_auth_smstext方法代码示例

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


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

示例1: SmsTokenClass

# 需要导入模块: from privacyidea.lib.policy import PolicyClass [as 别名]
# 或者: from privacyidea.lib.policy.PolicyClass import get_auth_smstext [as 别名]

#.........这里部分代码省略.........
        return request_is_valid

    ##
    ##!!! this function is to be called in the sms controller !!!
    ##
    @log_with(log)
    def submitChallenge(self, options=None):
        '''
        submit the sms message - former method name was checkPin

        :param options: the request options context

        :return: tuple of success and message
        '''
        res = 0
        user = None
        message = "<otp>"

        ## it is configurable, if sms should be triggered by a valid pin
        send_by_PIN = getFromConfig("sms.sendByPin") or True

        if self.isActive() == True and send_by_PIN == True :
            counter = self.getOtpCount()
            log.debug("counter=%r" % counter)
            self.incOtpCounter(counter, reset=False)
            # At this point we must not bail out in case of an
            # Gateway error, since checkPIN is successful. A bail
            # out would cancel the checking of the other tokens
            try:

                if options is not None and type(options) == dict:
                    user = options.get('user', None)
                    if user:
                        _sms_ret, message = self.Policy.get_auth_smstext(
                                                realm=user.realm)
                res, message = self.sendSMS(message=message)
                self.info['info'] = "SMS sent: %r" % res

            except Exception as e:
                # The PIN was correct, but the SMS could not be sent.
                self.info['info'] = unicode(e)
                info = ("The PIN was correct, but the"
                          " SMS could not be sent: %r" % e)
                log.warning(info)
                res = False
                message = info
        if len(message) == 0:
            pass

        return res, message


    def initChallenge(self, transactionid, challenges=None, options=None):
        """
        initialize the challenge -
        in the privacyidea server a challenge object has been allocated and
        this method is called to confirm the need of a new challenge
        or if for the challenge request, there is an already outstanding
        challenge to which then could be referred (s. ticket #2986)

        :param transactionid: the id of the new challenge
        :param options: the request parameters

        :return: tuple of
                success - bool
                transid - the best transaction id for this request context
开发者ID:asifiqbal,项目名称:privacyidea,代码行数:70,代码来源:smstoken.py


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