Ejemplo n.º 1
0
    def log_signingcert(self):
        if len(self.bdoc.signatures) != 1:
            raise Exception("BDoc sisaldab rohkem kui ühte allkirja")

        _, sig_content = self.bdoc.signatures.popitem()

        start = '<ds:X509Certificate>'
        end = '</ds:X509Certificate>'
        cert = sig_content.partition(start)[2].partition(end)[0].strip()

        alog, elog = evlogdata.get_cert_data_log(cert, 'signingcert', True)
        self.alines.append(alog)

        if elog:
            self.elines.append(elog)
Ejemplo n.º 2
0
    def log_signingcert(self):
        if len(self.bdoc.signatures) != 1:
           raise Exception, "BDoc sisaldab rohkem kui ühte allkirja"

        _, sig_content = self.bdoc.signatures.popitem()

        start = '<ds:X509Certificate>'
        end = '</ds:X509Certificate>'
        cert = sig_content.partition(start)[2].partition(end)[0].strip()

        alog, elog = evlogdata.get_cert_data_log(cert, 'signingcert', True)
        self.alines.append(alog)

        if elog:
            self.elines.append(elog)
Ejemplo n.º 3
0
def get_loglines(prefix):
    to_alog = []
    to_elog = []

    to_alog.append(prefix + " REMOTE_ADDR: " + evlogdata.get_remote_ip())
    to_alog.append(prefix + " HTTP_USER_AGENT: " + evlogdata.get_user_agent())

    if evcommon.HTTP_CERT in os.environ:
        cert = os.environ[evcommon.HTTP_CERT]
        if len(cert) > 0:
            alog, elog = evlogdata.get_cert_data_log(cert, prefix)
            to_alog.append(alog)
            if elog:
                to_elog.append(elog)

    return to_alog, to_elog
Ejemplo n.º 4
0
def get_loglines(prefix):
    to_alog = []
    to_elog = []

    to_alog.append(prefix + " REMOTE_ADDR: " + evlogdata.get_remote_ip())
    to_alog.append(prefix + " HTTP_USER_AGENT: " + evlogdata.get_user_agent())

    if evcommon.HTTP_CERT in os.environ:
        cert = os.environ[evcommon.HTTP_CERT]
        if len(cert) > 0:
            alog, elog = evlogdata.get_cert_data_log(cert, prefix)
            to_alog.append(alog)
            if elog:
                to_elog.append(elog)

    return to_alog, to_elog
Ejemplo n.º 5
0
    def init_auth(self, phone):

        try:
            evlog.log("Autentimispäring: ALGUS %s" % (phone))
            if not ElectionState().election_on():
                r1, r2 = ElectionState().election_off_msg()
                return protocol.msg_error(r1, r2)

            self.ctx().set_phone(phone)
            self.ctx().generate_challenge()
            service = MobileIDService()

            rsp_cert = service.get_cert(self.ctx())
            if not (rsp_cert._SignCertStatus == 'OK'):
                return self.__return_mid_error(rsp_cert._SignCertStatus)

            if rsp_cert._AuthCertStatus == 'OK':
                res, err = cert_ok(rsp_cert._AuthCertData)
                if not res:
                    evlog.log_error(err)
                    return self.__return_mid_policy_error()
            else:
                return self.__return_mid_error(rsp_cert._AuthCertStatus)

            rsp = service.init_auth(self.ctx())
            if rsp._Status == 'OK':
                self.ctx().save_post_auth(rsp)

                alog, elog = evlogdata.get_cert_data_log(
                        rsp._CertificateData, 'cand/auth', True)

                evlog.log('Autentimispäring (%s, %s, %s, %s)' % \
                    (rsp._UserIDCode, rsp._UserGivenname, \
                    rsp._UserSurname, rsp._Challenge))

                evlog.log(alog)
                if elog:
                    evlog.log_error(elog)

                return protocol.msg_mobid_auth_init_ok(\
                    self.ctx().sessid(), rsp._ChallengeID)

            return self.__return_mid_error(rsp._Status)

        except httplib.BadStatusLine, exc:
            return self.__return_badstatusline_error(exc)
Ejemplo n.º 6
0
    def init_auth(self, phone):

        try:
            evlog.log("Autentimispäring: ALGUS %s" % (phone))
            if not ElectionState().election_on():
                r1, r2 = ElectionState().election_off_msg()
                evlog.log_error('Viga operatsioonil "cand", teade "%s"' % r2)
                return protocol.msg_error(r1, r2)

            self.ctx().set_phone(phone)
            self.ctx().generate_challenge()
            service = MobileIDService()

            rsp = service.init_auth(self.ctx())
            if rsp._Status == 'OK':
                rsp._CertificateData = rsp._CertificateData.strip()

                self.ctx().save_post_auth(rsp)

                alog, elog = evlogdata.get_cert_data_log(
                    rsp._CertificateData, 'cand/auth', True)

                evlog.log('Autentimispäring (%s, %s, %s, %s)' %
                          (rsp._UserIDCode, rsp._UserGivenname,
                           rsp._UserSurname, rsp._Challenge))

                evlog.log(alog)
                if elog:
                    evlog.log_error(elog)

                return protocol.msg_mobid_auth_init_ok(self.ctx().sessid(),
                                                       rsp._ChallengeID)

            return self.__return_mid_error(rsp._Status)

        except httplib.BadStatusLine as exc:
            return self.__return_badstatusline_error(exc)
        except ZSI.FaultException as exc:
            return self.__return_zsi_error(exc)
        except:
            return self.__return_exception()
        finally:
            evlog.log('Autentimispäring: LÕPP')
Ejemplo n.º 7
0
    def init_auth(self, phone):

        try:
            evlog.log("Autentimispäring: ALGUS %s" % (phone))
            if not ElectionState().election_on():
                r1, r2 = ElectionState().election_off_msg()
                evlog.log_error('Viga operatsioonil "cand", teade "%s"' % r2)
                return protocol.msg_error(r1, r2)

            self.ctx().set_phone(phone)
            self.ctx().generate_challenge()
            service = MobileIDService()

            rsp = service.init_auth(self.ctx())
            if rsp._Status == "OK":
                rsp._CertificateData = rsp._CertificateData.strip()

                self.ctx().save_post_auth(rsp)

                alog, elog = evlogdata.get_cert_data_log(rsp._CertificateData, "cand/auth", True)

                evlog.log(
                    "Autentimispäring (%s, %s, %s, %s)"
                    % (rsp._UserIDCode, rsp._UserGivenname, rsp._UserSurname, rsp._Challenge)
                )

                evlog.log(alog)
                if elog:
                    evlog.log_error(elog)

                return protocol.msg_mobid_auth_init_ok(self.ctx().sessid(), rsp._ChallengeID)

            return self.__return_mid_error(rsp._Status)

        except httplib.BadStatusLine as exc:
            return self.__return_badstatusline_error(exc)
        except ZSI.FaultException as exc:
            return self.__return_zsi_error(exc)
        except:
            return self.__return_exception()
        finally:
            evlog.log("Autentimispäring: LÕPP")