Ejemplo n.º 1
0
 def update(self, param):
     """
     This method is called during the initialization process.
     :param param: parameters from the token init
     :type param: dict
     :return: None
     """
     param["otpkey"] = generate_password(size=self.otp_len)
     PasswordTokenClass.update(self, param)
    def test_03_class_methods(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = PasswordTokenClass(db_token)

        info = token.get_class_info()
        self.assertTrue(info.get("title") == "Password Token", info)

        info = token.get_class_info("title")
        self.assertTrue(info == "Password Token", info)
    def test_03_class_methods(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = PasswordTokenClass(db_token)

        info = token.get_class_info()
        self.assertTrue(info.get("title") == "Password Token", info)

        info = token.get_class_info("title")
        self.assertTrue(info == "Password Token", info)
Ejemplo n.º 4
0
 def update(self, param):
     """
     This method is called during the initialization process.
     :param param: parameters from the token init
     :type param: dict
     :return: None
     """
     # We always generate the registration code, so we need to set this parameter
     param["genkey"] = 1
     PasswordTokenClass.update(self, param)
 def test_01_create_token(self):
     db_token = Token(self.serial1, tokentype="pw")
     db_token.save()
     token = PasswordTokenClass(db_token)
     token.update({"otpkey": self.password})
     self.assertTrue(token.token.serial == self.serial1, token)
     self.assertTrue(token.token.tokentype == "pw", token.token.tokentype)
     self.assertTrue(token.type == "pw", token)
     class_prefix = token.get_class_prefix()
     self.assertTrue(class_prefix == "PW", class_prefix)
     self.assertTrue(token.get_class_type() == "pw", token)
Ejemplo n.º 6
0
 def update(self, param):
     """
     This method is called during the initialization process.
     :param param: parameters from the token init
     :type param: dict
     :return: None
     """
     if "genkey" in param:
         # We do not need the genkey! We generate anyway.
         # Otherwise genkey and otpkey will raise an exception in
         # PasswordTokenClass
         del param["genkey"]
     param["otpkey"] = generate_password(size=self.otp_len)
     PasswordTokenClass.update(self, param)
Ejemplo n.º 7
0
 def update(self, param):
     """
     This method is called during the initialization process.
     :param param: parameters from the token init
     :type param: dict
     :return: None
     """
     if "genkey" in param:
         # We do not need the genkey! We generate anyway.
         # Otherwise genkey and otpkey will raise an exception in
         # PasswordTokenClass
         del param["genkey"]
     param["otpkey"] = generate_password(size=self.otp_len)
     PasswordTokenClass.update(self, param)
Ejemplo n.º 8
0
 def get_init_detail(self, params=None, user=None):
     """
     At the end of the initialization we return the registration code.
     """
     response_detail = PasswordTokenClass.get_init_detail(self, params, user)
     params = params or {}
     secretHOtp = self.token.get_otpkey()
     registrationcode = secretHOtp.getKey()
     response_detail["registrationcode"] = registrationcode
     return response_detail
Ejemplo n.º 9
0
 def get_init_detail(self, params=None, user=None):
     """
     At the end of the initialization we return the registration code.
     """
     response_detail = PasswordTokenClass.get_init_detail(self, params, user)
     params = params or {}
     secretHOtp = self.token.get_otpkey()
     registrationcode = secretHOtp.getKey()
     response_detail["registrationcode"] = to_unicode(registrationcode)
     return response_detail
Ejemplo n.º 10
0
 def update(self, param):
     """
     This method is called during the initialization process.
     :param param: parameters from the token init
     :type param: dict
     :return: None
     """
     if "genkey" in param:
         # We do not need the genkey! We generate anyway.
         # Otherwise genkey and otpkey will raise an exception in
         # PasswordTokenClass
         del param["genkey"]
     if "registration.length" in param:
         size = param["registration.length"]
         del param["registration.length"]
     else:
         size = self.otp_len
     if "registration.contents" in param:
         contents = param["registration.contents"]
         del param["registration.contents"]
     else:
         contents = self.otp_contents
     param["otpkey"] = _generate_pin_from_policy(contents, size=int(size))
     PasswordTokenClass.update(self, param)
    def test_02_check_password(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = PasswordTokenClass(db_token)

        r = token.check_otp(self.password)
        self.assertTrue(r == 0, r)

        r = token.check_otp("wrong pw")
        self.assertTrue(r == -1, r)

        # check pin+otp:
        token.set_pin(self.serial1, "secretpin")
        r = token.authenticate("secretpin{0!s}".format(self.password))
        self.assertTrue(r, r)
 def test_01_create_token(self):
     db_token = Token(self.serial1, tokentype="pw")
     db_token.save()
     token = PasswordTokenClass(db_token)
     token.update({"otpkey": self.password})
     self.assertTrue(token.token.serial == self.serial1, token)
     self.assertTrue(token.token.tokentype == "pw", token.token.tokentype)
     self.assertTrue(token.type == "pw", token)
     class_prefix = token.get_class_prefix()
     self.assertTrue(class_prefix == "PW", class_prefix)
     self.assertTrue(token.get_class_type() == "pw", token)
    def test_02_check_password(self):
        db_token = Token.query.filter(Token.serial == self.serial1).first()
        token = PasswordTokenClass(db_token)

        r = token.check_otp(self.password)
        self.assertTrue(r == 0, r)

        r = token.check_otp("wrong pw")
        self.assertTrue(r == -1, r)

        # check pin+otp:
        token.set_pin(self.serial1, "secretpin")
        r = token.authenticate("secretpin%s" % self.password)
        self.assertTrue(r, r)
Ejemplo n.º 14
0
 def __init__(self, aToken):
     PasswordTokenClass.__init__(self, aToken)
     self.hKeyRequired = False
     self.set_type(u"registration")
     self.otp_len = 24
Ejemplo n.º 15
0
 def __init__(self, aToken):
     PasswordTokenClass.__init__(self, aToken)
     self.hKeyRequired = False
     self.set_type(u"registration")
     self.otp_len = 24
Ejemplo n.º 16
0
 def __init__(self, aToken):
     PasswordTokenClass.__init__(self, aToken)
     self.hKeyRequired = False
     self.set_type(u"registration")
     self.otp_len = DEFAULT_LENGTH
     self.otp_contents = DEFAULT_CONTENTS