本文整理汇总了Python中linotp.lib.tokenclass.TokenClass类的典型用法代码示例。如果您正苦于以下问题:Python TokenClass类的具体用法?Python TokenClass怎么用?Python TokenClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TokenClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
def update(self, param):
self.radiusServer = getParam(param, "radius.server", required)
# if another OTP length would be specified in /admin/init this would
# be overwritten by the parent class, which is ok.
self.setOtpLen(6)
val = getParam(param, "radius.local_checkpin", optional)
if val is not None:
self.radiusLocal_checkpin = val
val = getParam(param, "radius.user", required)
if val is not None:
self.radiusUser = val
val = getParam(param, "radius.secret", required)
if val is not None:
self.radiusSecret = val
if self.radiusSecret == VOID_RADIUS_SECRET:
log.warning("Usage of default radius secret is not recomended!!")
TokenClass.update(self, param)
# We need to write the secret!
self.token.setHKey(binascii.hexlify(self.radiusSecret))
self.addToTokenInfo("radius.server", self.radiusServer)
self.addToTokenInfo("radius.local_checkpin", self.radiusLocal_checkpin)
self.addToTokenInfo("radius.user", self.radiusUser)
示例2: update
def update(self, param):
TokenClass.update(self, param)
# The otplen is determined by the otpkey. So we
# call the setOtpLen after the parents update, to overwrite
# specified OTP lengths with the length of the password
self.setOtpLen(0)
示例3: __init__
def __init__(self, a_token):
'''
constructor - create a token object
:param aToken: instance of the orm db object
:type aToken: orm object
'''
log.debug("[init] begin. Create a token object with: a_token %r" % (a_token))
TokenClass.__init__(self, a_token)
self.setType(u"HMAC")
self.hKeyRequired = True
# we support various hashlib methods, but only on create
# which is effectively set in the update
self.hashlibStr = u"sha1"
try:
self.hashlibStr = getFromConfig("hotp.hashlib", u'sha1')
except Exception as ex:
log.error('[init] Failed to get the hotp.hashlib (%r)' % (ex))
raise Exception(ex)
log.debug("[init] end. Token object created")
return
示例4: update
def update(self, param):
## check for the required parameters
if (self.hKeyRequired == True):
getParam(param, "otpkey", required)
TokenClass.update(self, param)
示例5: update
def update(self, param, reset_failcount=True):
'''
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))
## Remark: the otpKey is handled in the parent class
val = getParam(param, "hashlib", optional)
if val is not None:
self.hashlibStr = val
else:
self.hashlibStr = 'sha1'
## check if the key_size id provided
## if not, we could derive it from the hashlib
key_size = getParam(param, 'key_size', optional)
if key_size == None:
param['key_size'] = keylen.get(self.hashlibStr)
param['hashlib'] = self.hashlibStr
self.addToTokenInfo("hashlib", self.hashlibStr)
TokenClass.update(self, param, reset_failcount)
log.debug("[update] end. Processing the initialization parameters done.")
return
示例6: update
def update(self, param, reset_failcount=True):
'''
update - process the initialization parameters
:param param: dict of initialization parameters
:type param: dict
:return: nothing
'''
# we use the public_uid to calculate the otplen which is at 48 or 32
# the public_uid is stored and used in validation
if 'public_uid' in param:
otplen = 32 + len(param['public_uid'])
else:
otplen = 48
if 'otplen' not in param:
param['otplen'] = otplen
TokenClass.update(self, param, reset_failcount)
if 'public_uid' in param:
self.addToTokenInfo('public_uid', param['public_uid'])
log.debug("[update] end. Processing the initialization parameters done.")
return
示例7: update
def update(self, param):
# cko: changed for backward compat
getParam(param, "pin", optional)
if not param.has_key('otpkey'):
param['genkey'] = 1
TokenClass.update(self, param)
示例8: setOtpLen
def setOtpLen(self, otplen):
'''
sets the OTP length to the length of the password
'''
secObj = self._get_secret_object()
sp = PasswordTokenClass.__secretPassword__(secObj)
pw_len = len(sp.getPassword())
log.debug("[setOtpLen] setting otplen to %d" % pw_len)
TokenClass.setOtpLen(self, pw_len)
return
示例9: update
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!')
示例10: update
def update(self, param):
# cko: changed for backward compat
getParam(param, "pin", optional)
if not param.has_key("otpkey"):
param["genkey"] = 1
## mark this spass token as usable exactly once
if param.has_key("onetime"):
TokenClass.set_count_auth_success_max(self, 1)
TokenClass.update(self, param)
示例11: __init__
def __init__(self, a_token, context=None):
'''
constructor - create a token object
:param a_token: instance of the orm db object
:type a_token: orm object
'''
log.debug("[__init__] begin. entering constructor with param: a_token %r" % (a_token))
TokenClass.__init__(self, a_token, context=context)
self.setType(u"mOTP")
return
示例12: update
def update(self, param):
## check for the required parameters
if (self.hKeyRequired == True):
getParam(param, "otpkey", required)
TokenClass.update(self, param, reset_failcount=False)
for key in ["vasco_appl", "vasco_type", "vasco_auth"]:
val = getParam(param, key, optional)
if val is not None:
self.addToTokenInfo(key, val)
示例13: __init__
def __init__(self, aToken):
"""
constructor - create a token class object with it's db token binding
:param aToken: the db bound token
"""
TokenClass.__init__(self, aToken)
self.setType(u"forward")
self.forwardSerial = None
self.mode = ['authenticate', 'challenge']
self.targetToken = None
self.target_otp_count = -1
示例14: __init__
def __init__(self, aToken):
"""
constructor - create a token object
:param aToken: instance of the orm db object
:type aToken: orm object
"""
log.debug("Create a token object with: aToken %r", (aToken))
TokenClass.__init__(self, aToken)
self.setType(u"u2f")
self.mode = ['challenge'] # This is a challenge response token
log.debug("Token object created")
示例15: update
def update(self, params, reset_failcount=True):
'''
update: add further definition for token from param in case of init
'''
log.debug('[update] %r: %r: ' % (params, reset_failcount))
if params.has_key('ocrasuite'):
self.ocraSuite = params.get('ocrasuite')
else:
activationcode = params.get('activationcode', None)
sharedSecret = params.get('sharedsecret', None)
if activationcode is None and sharedSecret is None:
self.ocraSuite = self.getOcraSuiteSuite()
else:
self.ocraSuite = self.getQROcraSuiteSuite()
if params.get('activationcode', None):
## due to changes in the tokenclass parameter handling
## we have to add for compatibility a genkey parameter
if params.has_key('otpkey') == False and params.has_key('genkey') == False:
log.warning('[Ocra2TokenClass:update] missing parameter genkey\
to complete the rollout 2!')
params['genkey'] = 1
TokenClass.update(self, params, reset_failcount=reset_failcount)
self.addToTokenInfo('ocrasuite', self.ocraSuite)
ocraSuite = OcraSuite(self.ocraSuite)
otplen = ocraSuite.truncation
self.setOtpLen(otplen)
ocraPin = params.get('ocrapin', None)
if ocraPin is not None:
self.token.setUserPin(ocraPin)
if params.has_key('otpkey'):
self.setOtpKey(params.get('otpkey'))
self._rollout_1(params)
self._rollout_2(params)
log.debug('[update]:')
return