Exemple #1
0
    def verify_vote(self, votedata):
        import regrights
        self.user_msg = \
            EvMessage().get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
            evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)

        conf = bdocpythonutils.BDocConfig()
        conf.load(Election().get_bdoc_conf())

        self.bdoc = bdocpythonutils.BDocContainer()
        self.bdoc.load_bytes(votedata)
        self.bdoc.validateflex()
        res = self.__check_incoming_vote(conf)

        if not res.result:
            self.log_msg = res.error
            if self.user_msg == '':
                self.user_msg = EvMessage().\
                    get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                        evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)

            if not res.ocsp_is_good:
                self.user_msg = EvMessage().\
                    get_str("SERTIFIKAAT_ON_TYHISTATUD_VOI_PEATATUD", \
                        evstrings.SERTIFIKAAT_ON_TYHISTATUD_VOI_PEATATUD)
                raise HTSStoreException, evcommon.EVOTE_CERT_ERROR

            raise HTSStoreException, evcommon.EVOTE_ERROR

        self.signercode = regrights.get_personal_code(res.subject)

        self.ocsp_time = res.ocsp_time
        self.signed_vote = self.bdoc.get_bytes()
Exemple #2
0
    def verify_vote(self, votedata):
        import regrights
        self.user_msg = EV_ERRORS.TEHNILINE_VIGA

        conf = bdocconfig.BDocConfig()
        conf.load(Election().get_bdoc_conf())

        self.bdoc = bdocpythonutils.BDocContainer()
        self.bdoc.load_bytes(votedata)
        self.bdoc.validateflex()
        res = self.__check_incoming_vote(conf)

        if not res.result:
            self.log_msg = res.error
            if self.user_msg == '':
                self.user_msg = EV_ERRORS.TEHNILINE_VIGA

            if not res.ocsp_is_good:
                self.user_msg = EV_ERRORS.SERTIFIKAAT_ON_TYHISTATUD_VOI_PEATATUD
                raise HTSStoreException(evcommon.EVOTE_CERT_ERROR)

            raise HTSStoreException(evcommon.EVOTE_ERROR)

        self.signercode = regrights.get_personal_code(res.subject)

        self.ocsp_time = res.ocsp_time
        self.signed_vote = self.bdoc.get_bytes()
Exemple #3
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocconfig.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            alines = []
            elines = []
            if mobid:
                alines, elines = regrights.analyze_signature_for_log(self._decoded_vote)
            else:
                alines, elines = regrights.analyze_vote_for_log(self._decoded_vote)

            for el in alines:
                evlog.log(el)

            for el in elines:
                evlog.log_error(el)

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == "":
                    self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg = evmessage.EV_ERRORS.SERTIFIKAAT_ON_AEGUNUD
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = "Autentija (%s) ja allkirjastaja (%s) erinevad" % (self._ik, ik_ver)
                self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemple #4
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocpythonutils.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == '':
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                            evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg = evmessage.EvMessage().\
                        get_str("SERTIFIKAAT_ON_AEGUNUD", \
                            evstrings.SERTIFIKAAT_ON_AEGUNUD)
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = \
                    'Autentija (%s) ja allkirjastaja (%s) erinevad' % \
                        (self._ik, ik_ver)
                self.error.user_msg = \
                    evmessage.EvMessage().get_str("ERINEV_KASUTAJA", \
                        evstrings.ERINEV_KASUTAJA)
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EvMessage().\
                get_str("TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL", \
                    evstrings.TEHNILINE_VIGA_HAALE_VERIFITSEERIMISEL)
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False
Exemple #5
0
    def check_vote(self, mobid):

        try:
            bdocpython.initialize()
            conf = bdocconfig.BDocConfig()
            conf.load(Election().get_bdoc_conf())

            alines = []
            elines = []
            if mobid:
                alines, elines = \
                    regrights.analyze_signature_for_log(self._decoded_vote)
            else:
                alines, elines = \
                    regrights.analyze_vote_for_log(self._decoded_vote)

            for el in alines:
                evlog.log(el)

            for el in elines:
                evlog.log_error(el)

            res = None
            if mobid:
                res = regrights.check_vote_hes_mobid(self._decoded_vote, conf)
            else:
                res = regrights.check_vote_hes(self._decoded_vote, conf)

            if not res.result:
                self.error.log_msg = res.error
                if self.error.user_msg == '':
                    self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR

                if not res.cert_is_valid:
                    self.error.user_msg =\
                        evmessage.EV_ERRORS.SERTIFIKAAT_ON_AEGUNUD
                    self.error.user_code = evcommon.EVOTE_CERT_ERROR

                return False

            ik_ver = regrights.get_personal_code(res.subject)
            if self._ik != ik_ver:
                self.error.log_msg = \
                    'Autentija (%s) ja allkirjastaja (%s) erinevad' % \
                    (self._ik, ik_ver)
                self.error.user_msg = \
                    evmessage.EV_ERRORS.TEHNILINE_VIGA
                self.error.user_code = evcommon.EVOTE_ERROR
                return False

            return True

        except:
            self.error.user_msg = evmessage.EV_ERRORS.TEHNILINE_VIGA
            self.error.user_code = evcommon.EVOTE_ERROR
            self.error.log_msg = exception_msg.trace()

        finally:
            bdocpython.terminate()

        return False