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


Python PolicyClass.get_qrtan_url方法代码示例

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


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

示例1: Ocra2TokenClass

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

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

        secretHOtp = self.token.getHOtpKey()
        ocraSuite = OcraSuite(self.getOcraSuiteSuite(), secretHOtp)

        if typ == 'raw':
            challenge = ocraSuite.data2rawChallenge(input)
        elif typ == 'random':
            challenge = ocraSuite.data2randomChallenge(input)
        elif typ == 'hash':
            challenge = ocraSuite.data2hashChallenge(input)

        log.debug('challenge: %r ' % (challenge))

        store_data = {
                'challenge' : "%s" % (challenge),
                'serial' : self.token.getSerial(),
                'input' : '',
                'url' : '',
                }

        if input is not None:
            store_data['input'] = input

        if session is not None:
            store_data["session"] = session

        res = self.verify_challenge_is_valid(challenge, session)

        ## add Info: so depending on the Info, the rendering could be done
        ##          as a callback into the token via
        ##          token.getQRImageData(opt=details)
        realms = self.token.getRealms()
        if len(realms) > 0:
            store_data["url"] = self.Policy.get_qrtan_url(realms[0].name)

        ## we will return a dict of all
        attributes = self.prepare_message(store_data, state)
        attributes['challenge'] = challenge

        if attributes != None and "data" in attributes:
            message = attributes.get("data")
            del attributes['data']

        return (res, message, store_data, attributes)

    def prepare_message(self, data, transId):
        '''
        prepare the challenge response message

        :param data:
        :param transId: the transaction/state refenence id
        remark:
        we need the state/transId in the inner scope to support the signing
        of the whole request including the state/transId
        '''

        url = data.get("url")
        u = (str(urllib.urlencode({'u': '%s' % url})))
        u = urllib.urlencode({'u': "%s" % (url.encode("utf-8"))})

        challenge = data.get('challenge')
        input = data.get('input')

        uInfo = {'tr': transId,
                 'ch': challenge,
                 'me': str(input.encode("utf-8")),
开发者ID:asifiqbal,项目名称:privacyidea,代码行数:70,代码来源:ocra2token.py


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