Exemple #1
0
 def _import(self):
     """
     (internal use only)
     imports existing x509 certificates
     """
     cert = self.x509
     # when importing an end entity certificate
     if hasattr(self, 'ca'):
         self._verify_ca()
     self.key_length = str(cert.get_pubkey().bits())
     # this line might fail if a certificate with
     # an unsupported signature algorithm is imported
     algorithm = cert.get_signature_algorithm().decode('utf8')
     self.digest = SIGNATURE_MAPPING[algorithm]
     not_before = cert.get_notBefore().decode('utf8')
     self.validity_start = datetime.strptime(not_before, generalized_time)
     self.validity_start = timezone.make_aware(self.validity_start)
     not_after = cert.get_notAfter().decode('utf8')
     self.validity_end = datetime.strptime(not_after, generalized_time)
     self.validity_end.replace(tzinfo=timezone.tzinfo())
     self.validity_end = timezone.make_aware(self.validity_end)
     subject = cert.get_subject()
     self.country_code = subject.countryName or ''
     self.state = subject.stateOrProvinceName or ''
     self.city = subject.localityName or ''
     self.organization = subject.organizationName or ''
     self.email = subject.emailAddress or ''
     self.common_name = subject.commonName
     self.serial_number = cert.get_serial_number()
     if not self.name:
         self.name = self.common_name
Exemple #2
0
def event_recurrent_data(condition_factory, activity, custom_user_factory,
                         place, organization):
    cond1 = condition_factory(organization=organization)
    cond2 = condition_factory(organization=organization)
    user1 = custom_user_factory()
    user2 = custom_user_factory()
    user3 = custom_user_factory()
    user4 = custom_user_factory()
    organization.actives.add(user1, user2, user3, user4)
    fix_date = datetime.datetime(3019,
                                 7,
                                 4,
                                 14,
                                 19,
                                 5,
                                 tzinfo=timezone.tzinfo())
    return {
        "activity":
        activity.pk,
        "available_seats":
        12,
        "organizers": [user4.pk],
        "conditions": [cond1.pk, cond2.pk],
        "location":
        place.pk,
        "organization":
        organization,
        "recurrent_type":
        "MONTHLY",
        "date":
        fix_date.date().strftime("%Y-%m-%d"),
        "days": ["MO", "TH"],
        "weeks": ["1", "2"],
        "starts_at":
        ((fix_date + datetime.timedelta(hours=4)).time().strftime("%H:%M")),
        "ends_at":
        ((fix_date + datetime.timedelta(hours=7)).time().strftime("%H:%M")),
        "end_date":
        ((fix_date + datetime.timedelta(days=90)).date().strftime("%Y-%m-%d")),
        "period_before_publish":
        2,
    }
Exemple #3
0
 def _import(self):
     """
     (internal use only)
     imports existing x509 certificates
     """
     cert = self.x509
     # when importing an end entity certificate
     if hasattr(self, 'ca'):
         self._verify_ca()
     self.key_length = str(cert.get_pubkey().bits())
     # this line might fail if a certificate with
     # an unsupported signature algorithm is imported
     algorithm = cert.get_signature_algorithm().decode('utf8')
     self.digest = SIGNATURE_MAPPING[algorithm]
     not_before = cert.get_notBefore().decode('utf8')
     self.validity_start = datetime.strptime(not_before,
                                             generalized_time)
     self.validity_start = timezone.make_aware(self.validity_start)
     not_after = cert.get_notAfter().decode('utf8')
     self.validity_end = datetime.strptime(not_after,
                                           generalized_time)
     self.validity_end.replace(tzinfo=timezone.tzinfo())
     self.validity_end = timezone.make_aware(self.validity_end)
     subject = cert.get_subject()
     self.country_code = subject.countryName or ''
     # allow importing from legacy systems which use invalid country codes
     if len(self.country_code) > 2:
         self.country_code = ''
     self.state = subject.stateOrProvinceName or ''
     self.city = subject.localityName or ''
     self.organization_name = subject.organizationName or ''
     self.organizational_unit_name = subject.organizationalUnitName or ''
     self.email = subject.emailAddress or ''
     self.common_name = subject.commonName or ''
     self.serial_number = cert.get_serial_number()
     if not self.name:
         self.name = self.common_name or str(self.serial_number)