本文整理汇总了Python中linotp.lib.tokens.hmactoken.HmacTokenClass.update方法的典型用法代码示例。如果您正苦于以下问题:Python HmacTokenClass.update方法的具体用法?Python HmacTokenClass.update怎么用?Python HmacTokenClass.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linotp.lib.tokens.hmactoken.HmacTokenClass
的用法示例。
在下文中一共展示了HmacTokenClass.update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param, reset_failcount=True):
'''
update - process initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
'''
log.debug("[update] begin. adjust the token class with: param %r"
% (param))
# specific - phone
phone = getParam(param, "phone", required)
self.setPhone(phone)
## in case of the sms token, only the server must know the otpkey
## thus if none is provided, we let create one (in the TokenClass)
if not param.has_key('genkey') and not param.has_key('otpkey'):
param['genkey'] = 1
HmacTokenClass.update(self, param, reset_failcount)
log.debug("[update] end. all token parameters are set.")
return
示例2: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param, reset_failcount=True):
"""
update - process initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
"""
LOG.debug("[update] begin. adjust the token class with: param %r" % param)
# specific - e-mail
self._email_address = param[self.EMAIL_ADDRESS_KEY]
# in scope selfservice - check if edit_email is allowed
# if not allowed to edit, check if the email is the same
# as from the user data
if param.get('::scope::', {}).get('selfservice', False):
user = param['::scope::']['user']
if not is_email_editable(user):
u_info = getUserDetail(user)
u_email = u_info.get('email', None)
if u_email.strip() != self._email_address.strip():
raise Exception(_('User is not allowed to set email address'))
## in case of the e-mail token, only the server must know the otpkey
## thus if none is provided, we let create one (in the TokenClass)
if not 'genkey' in param and not 'otpkey' in param:
param['genkey'] = 1
HmacTokenClass.update(self, param, reset_failcount)
LOG.debug("[update] end. all token parameters are set.")
return
示例3: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param, reset_failcount=True):
'''
update - process initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
'''
_ = context['translate']
log.debug("[update] begin. adjust the token class with: param %r"
% (param))
# specific - phone
phone = getParam(param, "phone", required)
# in scope selfservice - check if edit_sms is allowed
# if not allowed to edit, check if the phone is the same
# as from the user data
if param.get('::scope::', {}).get('selfservice', False):
user = param['::scope::']['user']
if not is_phone_editable(user):
u_info = getUserDetail(user)
u_phone = u_info.get('mobile', u_info.get('phone', None))
if u_phone != phone:
raise Exception(_('User is not allowed to '
'set phone number'))
self.setPhone(phone)
# in case of the sms token, only the server must know the otpkey
# thus if none is provided, we let create one (in the TokenClass)
if 'genkey' not in param and 'otpkey' not in param:
param['genkey'] = 1
HmacTokenClass.update(self, param, reset_failcount)
log.debug("[update] end. all token parameters are set.")
return
示例4: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param, reset_failcount=True):
"""
update - process initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
"""
log.debug("[update] begin. adjust the token class with: param %r" % (param))
# specific - phone
phone = getParam(param, "phone", required)
# in scope selfservice - check if edit_sms is allowed
# if not allowed to edit, check if the phone is the same
# as from the user data
if param.get("::scope::", {}).get("selfservice", False):
user = param["::scope::"]["user"]
if not is_phone_editable(user):
u_info = getUserDetail(user)
u_phone = u_info.get("mobile", u_info.get("phone", None))
if u_phone != phone:
raise Exception(_("User is not allowed to " "set phone number"))
self.setPhone(phone)
# in case of the sms token, only the server must know the otpkey
# thus if none is provided, we let create one (in the TokenClass)
if "genkey" not in param and "otpkey" not in param:
param["genkey"] = 1
HmacTokenClass.update(self, param, reset_failcount)
log.debug("[update] end. all token parameters are set.")
return
示例5: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param, reset_failcount=True):
"""
update - process initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
"""
LOG.debug("[update] begin. adjust the token class with: param %r" % param)
# specific - e-mail
self._email_address = getParam(param, self.EMAIL_ADDRESS_KEY, optional=False)
## in case of the e-mail token, only the server must know the otpkey
## thus if none is provided, we let create one (in the TokenClass)
if not 'genkey' in param and not 'otpkey' in param:
param['genkey'] = 1
HmacTokenClass.update(self, param, reset_failcount)
LOG.debug("[update] end. all token parameters are set.")
return
示例6: update
# 需要导入模块: from linotp.lib.tokens.hmactoken import HmacTokenClass [as 别名]
# 或者: from linotp.lib.tokens.hmactoken.HmacTokenClass import update [as 别名]
def update(self, param):
'''
update - process the initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
'''
log.debug("[update] begin. Process the initialization parameters: param %r" % (param))
## check for the required parameters
val = getParam(param, "hashlib", optional)
if val is not None:
self.hashlibStr = val
else:
self.hashlibStr = 'sha1'
otpKey = ''
if (self.hKeyRequired == True):
genkey = int(getParam(param, "genkey", optional) or 0)
if 1 == genkey:
# if hashlibStr not in keylen dict, this will raise an Exception
otpKey = generate_otpkey(keylen.get(self.hashlibStr))
del param['genkey']
else:
# genkey not set: check otpkey is given
# this will raise an exception if otpkey is not present
otpKey = getParam(param, "otpkey", required)
# finally set the values for the update
param['otpkey'] = otpKey
param['hashlib'] = self.hashlibStr
val = getParam(param, "otplen", optional)
if val is not None:
self.setOtpLen(int(val))
else:
self.setOtpLen(getFromConfig("DefaultOtpLen"))
val = getParam(param, "timeStep", optional)
if val is not None:
self.timeStep = val
val = getParam(param, "timeWindow", optional)
if val is not None:
self.timeWindow = val
val = getParam(param, "timeShift", optional)
if val is not None:
self.timeShift = val
HmacTokenClass.update(self, param)
self.addToTokenInfo("timeWindow", self.timeWindow)
self.addToTokenInfo("timeShift", self.timeShift)
self.addToTokenInfo("timeStep", self.timeStep)
self.addToTokenInfo("hashlib", self.hashlibStr)
log.debug("[update] end. Processing the initialization parameters done.")
return