当前位置: 首页>>代码示例>>Python>>正文


Python oid.ObjectIdentifier方法代码示例

本文整理汇总了Python中cryptography.x509.oid.ObjectIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Python oid.ObjectIdentifier方法的具体用法?Python oid.ObjectIdentifier怎么用?Python oid.ObjectIdentifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cryptography.x509.oid的用法示例。


在下文中一共展示了oid.ObjectIdentifier方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, oid, value):
        if not isinstance(oid, ObjectIdentifier):
            raise TypeError(
                "oid argument must be an ObjectIdentifier instance."
            )

        if not isinstance(value, six.text_type):
            raise TypeError(
                "value argument must be a text type."
            )

        if oid == NameOID.COUNTRY_NAME and len(value.encode("utf8")) != 2:
            raise ValueError(
                "Country name must be a 2 character country code"
            )

        self._oid = oid
        self._value = value 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:name.py

示例2: test_config

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def test_config(self):
        self.assertTrue(issubclass(self.ext_class, Extension))
        self.assertEqual(self.ext_class.key, self.ext_class_key)
        self.assertEqual(self.ext_class.name, self.ext_class_name)

        # Test some basic properties (just to be sure)
        self.assertIsInstance(self.ext_class.oid, ObjectIdentifier)
        self.assertIsInstance(self.ext_class.key, str)
        self.assertGreater(len(self.ext_class.key), 0)
        self.assertIsInstance(self.ext_class.name, str)
        self.assertGreater(len(self.ext_class.name), 0)

        # Test mapping dicts
        self.assertEqual(KEY_TO_EXTENSION[self.ext_class.key], self.ext_class)
        self.assertEqual(OID_TO_EXTENSION[self.ext_class.oid], self.ext_class)

        # test that the model matches
        self.assertTrue(hasattr(X509CertMixin, self.ext_class.key))
        self.assertIsInstance(getattr(X509CertMixin, self.ext_class.key), cached_property) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:21,代码来源:tests_extensions.py

示例3: oid_to_json

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def oid_to_json(obj: ObjectIdentifier) -> Dict[str, str]:
    return {"name": obj._name, "dotted_string": obj.dotted_string}


# We use dataclasses here to ensure consistency in how we serialize X509 names 
开发者ID:nabla-c0d3,项目名称:sslyze,代码行数:7,代码来源:_json_output.py

示例4: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, oid, value):
        if not isinstance(oid, ObjectIdentifier):
            raise TypeError(
                "oid argument must be an ObjectIdentifier instance."
            )

        if not isinstance(value, six.text_type):
            raise TypeError(
                "value argument must be a text type."
            )

        self._oid = oid
        self._value = value 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:15,代码来源:name.py

示例5: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, value):
        if not isinstance(value, ObjectIdentifier):
            raise TypeError("value must be an ObjectIdentifier")

        self._value = value 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:7,代码来源:general_name.py

示例6: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, oid, value, _type=_SENTINEL):
        if not isinstance(oid, ObjectIdentifier):
            raise TypeError(
                "oid argument must be an ObjectIdentifier instance."
            )

        if not isinstance(value, six.text_type):
            raise TypeError(
                "value argument must be a text type."
            )

        if (
            oid == NameOID.COUNTRY_NAME or
            oid == NameOID.JURISDICTION_COUNTRY_NAME
        ):
            if len(value.encode("utf8")) != 2:
                raise ValueError(
                    "Country name must be a 2 character country code"
                )

        if len(value) == 0:
            raise ValueError("Value cannot be an empty string")

        # The appropriate ASN1 string type varies by OID and is defined across
        # multiple RFCs including 2459, 3280, and 5280. In general UTF8String
        # is preferred (2459), but 3280 and 5280 specify several OIDs with
        # alternate types. This means when we see the sentinel value we need
        # to look up whether the OID has a non-UTF8 type. If it does, set it
        # to that. Otherwise, UTF8!
        if _type == _SENTINEL:
            _type = _NAMEOID_DEFAULT_TYPE.get(oid, _ASN1Type.UTF8String)

        if not isinstance(_type, _ASN1Type):
            raise TypeError("_type must be from the _ASN1Type enum")

        self._oid = oid
        self._value = value
        self._type = _type 
开发者ID:tp4a,项目名称:teleport,代码行数:40,代码来源:name.py

示例7: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, oid, value, _type=_SENTINEL):
        if not isinstance(oid, ObjectIdentifier):
            raise TypeError(
                "oid argument must be an ObjectIdentifier instance."
            )

        if not isinstance(value, six.text_type):
            raise TypeError(
                "value argument must be a text type."
            )

        if (
            oid == NameOID.COUNTRY_NAME or
            oid == NameOID.JURISDICTION_COUNTRY_NAME
        ):
            if len(value.encode("utf8")) != 2:
                raise ValueError(
                    "Country name must be a 2 character country code"
                )

        # The appropriate ASN1 string type varies by OID and is defined across
        # multiple RFCs including 2459, 3280, and 5280. In general UTF8String
        # is preferred (2459), but 3280 and 5280 specify several OIDs with
        # alternate types. This means when we see the sentinel value we need
        # to look up whether the OID has a non-UTF8 type. If it does, set it
        # to that. Otherwise, UTF8!
        if _type == _SENTINEL:
            _type = _NAMEOID_DEFAULT_TYPE.get(oid, _ASN1Type.UTF8String)

        if not isinstance(_type, _ASN1Type):
            raise TypeError("_type must be from the _ASN1Type enum")

        self._oid = oid
        self._value = value
        self._type = _type 
开发者ID:tp4a,项目名称:teleport,代码行数:37,代码来源:name.py

示例8: policy_identifier

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def policy_identifier(self, value):
        if isinstance(value, str):
            value = ObjectIdentifier(value)
        self._policy_identifier = value 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:extensions.py

示例9: parse_value

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def parse_value(self, v):
        if isinstance(v, ObjectIdentifier) and v in self._CRYPTOGRAPHY_MAPPING_REVERSED:
            return v
        elif isinstance(v, str) and v in self.CRYPTOGRAPHY_MAPPING:
            return self.CRYPTOGRAPHY_MAPPING[v]
        raise ValueError('Unknown value: %s' % v) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:8,代码来源:extensions.py

示例10: test_policy_identifier_setter

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def test_policy_identifier_setter(self):
        value = '1.2.3'
        expected = ObjectIdentifier(value)
        pi = PolicyInformation({'policy_identifier': value})
        pi.policy_identifier = value
        self.assertEqual(pi.policy_identifier, expected)

        pi = PolicyInformation({'policy_identifier': expected})
        self.assertEqual(pi.policy_identifier, expected)

        new_value = '2.3.4'
        new_expected = ObjectIdentifier(new_value)
        pi.policy_identifier = new_value
        self.assertEqual(pi.policy_identifier, new_expected) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:16,代码来源:tests_extensions.py

示例11: test_completeness

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def test_completeness(self):
        # make sure we support all ExtendedKeyUsageOIDs
        for attr in [getattr(ExtendedKeyUsageOID, a) for a in dir(ExtendedKeyUsageOID) if a[0] != '_']:
            if isinstance(attr, ObjectIdentifier):
                self.assertIn(attr, ExtendedKeyUsage._CRYPTOGRAPHY_MAPPING_REVERSED)

        # make sure we haven't forgotton any keys in the form selection
        self.assertEqual(set(ExtendedKeyUsage.CRYPTOGRAPHY_MAPPING.keys()),
                         set([e[0] for e in ExtendedKeyUsage.CHOICES])) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:11,代码来源:tests_extensions.py

示例12: __init__

# 需要导入模块: from cryptography.x509 import oid [as 别名]
# 或者: from cryptography.x509.oid import ObjectIdentifier [as 别名]
def __init__(self, oid, value, _type=_SENTINEL):
        if not isinstance(oid, ObjectIdentifier):
            raise TypeError(
                "oid argument must be an ObjectIdentifier instance."
            )

        if not isinstance(value, six.text_type):
            raise TypeError(
                "value argument must be a text type."
            )

        if (
            oid == NameOID.COUNTRY_NAME or
            oid == NameOID.JURISDICTION_COUNTRY_NAME
        ):
            if len(value.encode("utf8")) != 2:
                raise ValueError(
                    "Country name must be a 2 character country code"
                )

            if _type == _SENTINEL:
                _type = _ASN1Type.PrintableString

        if len(value) == 0:
            raise ValueError("Value cannot be an empty string")

        # Set the default string type for encoding ASN1 strings to UTF8. This
        # is the default for newer OpenSSLs for several years (1.0.1h+) and is
        # recommended in RFC 2459.
        if _type == _SENTINEL:
            _type = _ASN1Type.UTF8String

        if not isinstance(_type, _ASN1Type):
            raise TypeError("_type must be from the _ASN1Type enum")

        self._oid = oid
        self._value = value
        self._type = _type 
开发者ID:aws-quickstart,项目名称:quickstart-git2s3,代码行数:40,代码来源:name.py


注:本文中的cryptography.x509.oid.ObjectIdentifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。