本文整理汇总了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")),