diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-02-11 18:50:58 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-02-12 18:58:14 -0600 |
commit | e901d642548dd268dcdc2efa60087a3fa1774fa6 (patch) | |
tree | da7929e437b78ed212b8790d73fd7eaf2c58aef1 /src | |
parent | 719d536dd691e84e208534798f2eb4f82aaa2e07 (diff) | |
download | cryptography-e901d642548dd268dcdc2efa60087a3fa1774fa6.tar.gz cryptography-e901d642548dd268dcdc2efa60087a3fa1774fa6.tar.bz2 cryptography-e901d642548dd268dcdc2efa60087a3fa1774fa6.zip |
refactor x509.Name to use get_attributes_by_oid
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/x509.py | 2 | ||||
-rw-r--r-- | src/cryptography/x509.py | 62 |
2 files changed, 2 insertions, 62 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index e27d32f8..6bc7137c 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -107,7 +107,7 @@ class _Certificate(object): def _build_x509_name(self, x509_name): count = self._backend._lib.X509_NAME_entry_count(x509_name) attributes = [] - for x in range(0, count): + for x in range(count): entry = self._backend._lib.X509_NAME_get_entry(x509_name, x) obj = self._backend._lib.X509_NAME_ENTRY_get_object(entry) assert obj != self._backend._ffi.NULL diff --git a/src/cryptography/x509.py b/src/cryptography/x509.py index 2371b36c..7eb9a608 100644 --- a/src/cryptography/x509.py +++ b/src/cryptography/x509.py @@ -108,70 +108,10 @@ class Name(object): def __init__(self, attributes): self._attributes = attributes - def _filter_attr_list(self, oid): + def get_attributes_for_oid(self, oid): return [i for i in self._attributes if i.oid == oid] @property - def common_name(self): - return self._filter_attr_list(OID_COMMON_NAME) - - @property - def country_name(self): - return self._filter_attr_list(OID_COUNTRY_NAME) - - @property - def locality_name(self): - return self._filter_attr_list(OID_LOCALITY_NAME) - - @property - def state_or_province_name(self): - return self._filter_attr_list(OID_STATE_OR_PROVINCE_NAME) - - @property - def organization_name(self): - return self._filter_attr_list(OID_ORGANIZATION_NAME) - - @property - def organizational_unit_name(self): - return self._filter_attr_list(OID_ORGANIZATIONAL_UNIT_NAME) - - @property - def serial_number(self): - return self._filter_attr_list(OID_SERIAL_NUMBER) - - @property - def surname(self): - return self._filter_attr_list(OID_SURNAME) - - @property - def given_name(self): - return self._filter_attr_list(OID_GIVEN_NAME) - - @property - def title(self): - return self._filter_attr_list(OID_TITLE) - - @property - def generation_qualifier(self): - return self._filter_attr_list(OID_GENERATION_QUALIFIER) - - @property - def dn_qualifier(self): - return self._filter_attr_list(OID_DN_QUALIFIER) - - @property - def pseudonym(self): - return self._filter_attr_list(OID_PSEUDONYM) - - @property - def domain_component(self): - return self._filter_attr_list(OID_DOMAIN_COMPONENT) - - @property - def email_address(self): - return self._filter_attr_list(OID_EMAIL_ADDRESS) - - @property def attributes(self): return self._attributes[:] |