def init_1_QR_Token(self, activationkey=None, tokentype='ocra', serial=None, user=None, pin='pin', message='Message', ocrapin='', genkey='1', ocrasuite='OCRA-1:HOTP-SHA256-8:C-QA64'): ''' -2- acivate ocra token ''' parameters = {} if tokentype != None: parameters['type'] = tokentype if pin != None: parameters['pin'] = pin if message != None: parameters['message'] = message if genkey != None: parameters['genkey'] = genkey if ocrapin != None: parameters['ocrapin'] = ocrapin if user != None: parameters['user'] = user elif serial != None: parameters['serial'] = serial if activationkey == None: activationkey = createActivationCode('1234567890') parameters['activationcode'] = activationkey if ocrasuite != None: parameters['ocrasuite'] = ocrasuite response = self.app.get(genUrl(controller='admin', action='init'), params=parameters) return (response, activationkey)
def getActivationCode(self): ''' method: ocra/getActivationCode description: returns an valid example activcation code arguments: ./. returns: JSON with "activationcode": "JZXW4ZI=2A" ''' from linotp.lib.crypt import createActivationCode res = {} #description = 'ocra/getActivationCode' try: params = getLowerParams(request.params) log.debug("[getActivationCode]: %r" % params) checkPolicyPre('ocra', "activationcode") ac = str(params.get('activationcode')) activationCode = createActivationCode(acode=ac) res = {'activationcode':activationCode} Session.commit() return sendResult(response, res, 1) except PolicyException as pe: log.error("[getActivationCode] policy failed: %r" % pe) log.error("[getActivationCode] %s" % traceback.format_exc()) Session.rollback() return sendError(response, unicode(pe)) except Exception as exx: log.error("[getActivationCode] failed: %r" % exx) log.error("[getActivationCode] %s" % traceback.format_exc()) Session.rollback() return sendError(response, unicode(exx), 0) finally: Session.close() log.debug('[getActivationCode] done')
def getActivationCode(self): ''' method: orcra/getActivationCode description: returns an valid example activcation code arguments: ./. returns: JSON with "activationcode": "JZXW4ZI=2A" ''' from linotp.lib.crypt import createActivationCode res = {} #description = 'ocra/getActivationCode' try: params = getLowerParams(request.params) log.debug("[getActivationCode]: %r" % params) checkPolicyPre('ocra', "activationcode") ac = str(params.get('activationcode')) activationCode = createActivationCode(acode=ac) res = {'activationcode': activationCode} Session.commit() return sendResult(response, res, 1) except PolicyException as pe: log.error("[getActivationCode] policy failed: %r" % pe) log.error("[getActivationCode] %s" % traceback.format_exc()) Session.rollback() return sendError(response, unicode(pe)) except Exception as exx: log.error("[getActivationCode] failed: %r" % exx) log.error("[getActivationCode] %s" % traceback.format_exc()) Session.rollback() return sendError(response, unicode(exx), 0) finally: Session.close() log.debug('[getActivationCode] done')
def getActivationCode(self): """ method: ocra/getActivationCode description: returns an valid example activcation code arguments: ./. returns: JSON with "activationcode": "JZXW4ZI=2A" """ from linotp.lib.crypt import createActivationCode res = {} # description = 'ocra/getActivationCode' try: params = getLowerParams(request.params) log.debug("[getActivationCode]: %r" % params) checkPolicyPre("ocra", "activationcode", context=self.request_context) ac = str(params.get("activationcode")) activationCode = createActivationCode(acode=ac) res = {"activationcode": activationCode} Session.commit() return sendResult(response, res, 1) except PolicyException as pe: log.exception("[getActivationCode] policy failed: %r" % pe) Session.rollback() return sendError(response, unicode(pe)) except Exception as exx: log.exception("[getActivationCode] failed: %r" % exx) Session.rollback() return sendError(response, unicode(exx), 0) finally: Session.close() log.debug("[getActivationCode] done")
def init_1_QR_Token( self, activationkey=None, tokentype="ocra", serial=None, user=None, pin="pin", message="Message", ocrapin="", genkey="1", ocrasuite="OCRA-1:HOTP-SHA256-8:C-QA64", ): """ -2- acivate ocra token """ parameters = {} if tokentype != None: parameters["type"] = tokentype if pin != None: parameters["pin"] = pin if message != None: parameters["message"] = message if genkey != None: parameters["genkey"] = genkey if ocrapin != None: parameters["ocrapin"] = ocrapin if user != None: parameters["user"] = user elif serial != None: parameters["serial"] = serial if activationkey == None: activationkey = createActivationCode("1234567890") parameters["activationcode"] = activationkey if ocrasuite != None: parameters["ocrasuite"] = ocrasuite response = self.app.get(genUrl(controller="admin", action="init"), params=parameters) return (response, activationkey)