本文整理汇总了Python中linotp.lib.tokenclass.TokenClass.setPin方法的典型用法代码示例。如果您正苦于以下问题:Python TokenClass.setPin方法的具体用法?Python TokenClass.setPin怎么用?Python TokenClass.setPin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linotp.lib.tokenclass.TokenClass
的用法示例。
在下文中一共展示了TokenClass.setPin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from linotp.lib.tokenclass import TokenClass [as 别名]
# 或者: from linotp.lib.tokenclass.TokenClass import setPin [as 别名]
def update(self, param, reset_failcount=False):
self.setSyncWindow(0)
self.setOtpLen(32)
self.setCounterWindow(0)
tdesc = getParam(param, "description", optional)
if tdesc is not None:
self.token.setDescription(tdesc)
# requested_phase must be either "registration1" or "registration2"
# current_phase is either "registration" or "authentication"
requested_phase = getParam(param, "phase", optional)
current_phase = self.getFromTokenInfo("phase", None)
if requested_phase == "registration1" and current_phase is None:
# This initial registration phase triggers a challenge
# which is sent to the FIDO U2F compatible client device
# Set the optional token pin in this first phase
pin = getParam(param, "pin", optional)
if pin is not None:
TokenClass.setPin(self, pin)
# preserve the registration state
self.addToTokenInfo("phase", "registration")
self.token.LinOtpIsactive = False
elif requested_phase == "registration2" and current_phase == "registration":
# Check the token pin
pin = getParam(param, "pin", optional)
if pin is None:
pin = ""
if check_pin(self, pin) is False:
log.error("Wrong token pin!")
raise ValueError("Wrong token pin!")
# check for set phases which are not "registration1" or "registration2"
elif requested_phase != "registration2" and requested_phase is not None:
log.error("Wrong phase parameter!")
raise Exception("Wrong phase parameter!")
# only allow empty phase parameters once the token is registered successfully
elif current_phase != "authentication" and requested_phase is None:
log.error("Wrong phase parameter!")
raise Exception("Wrong phase parameter!")
# only allow "registration2" if the token already completed "registration1"
elif current_phase != "registration" and requested_phase == "registration2":
log.error(
"Phase 'registration2' requested but we are not in the correct phase \
to process the request."
)
raise Exception(
"Phase 'registration2' requested but we are not in the correct phase \
to process the request."
)
else:
log.error('Unknown "phase" and "current_phase" parameter combination!')
raise Exception('Unknown "phase" and "current_phase" parameter combination!')