Example #1
0
    def checkOtp(self, anOtpVal, counter, window, options=None):
        '''
        Checks if the OTP value is valid.

        Therefore the vasco data blob is fetched from the database and this very
        blob and the otp value is passed to the vasco function vasco_otp_check.

        After that the modified vasco blob needs to be stored (updated) in the
        database again.
        '''
        res = -1

        secObject = self.token.getHOtpKey()
        otpkey = secObject.getKey()
        # let vasco handle the OTP checking
        ret = vasco_otp_check(otpkey, anOtpVal)
        if ret is None:
            log.info("Failed to authenticate due to missing vasco dll!")
            return -1

        # if all is ok, we get the result tupple from the return
        (res, otpkey) = ret

        # update the vasco data blob
        self.update({"otpkey": otpkey})

        if res != 0:
            log.warning("[checkOtp] Vasco token failed to authenticate. "
                        "Vasco Error code: %d" % res)
            # TODO: Vasco gives much more detailed error codes. But at the
            # moment we do not handle more error codes!
            res = -1

        return res
Example #2
0
    def checkOtp(self, anOtpVal, counter, window, options=None):
        '''
        Checks if the OTP value is valid.

        Therefore the vasco data blob is fetched from the database and this very
        blob and the otp value is passed to the vasco function vasco_otp_check.

        After that the modified vasco blob needs to be stored (updated) in the
        database again.
        '''
        res = -1

        secObject = self.token.getHOtpKey()
        otpkey = secObject.getKey()
        data = decompress(otpkey)
        # let vasco handle the OTP checking
        (res, data) = vasco_otp_check(data, anOtpVal)
        # update the vasco data blob
        self.update({"otpkey" : compress(data)})

        if res != 0:
            log.warning("[checkOtp] Vasco token failed to authenticate. Vasco Error code: %d" % res)
            # TODO: Vasco gives much more detailed error codes. But at the moment we do not handle more error codes!
            res = -1

        return res