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


Python x509.NoticeReference方法代码示例

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


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

示例1: parse_policy_qualifier

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import NoticeReference [as 别名]
def parse_policy_qualifier(self, qualifier):
        if isinstance(qualifier, str):
            return force_text(qualifier)
        elif isinstance(qualifier, x509.UserNotice):
            return qualifier
        elif isinstance(qualifier, dict):
            explicit_text = qualifier.get('explicit_text')

            notice_reference = qualifier.get('notice_reference')
            if isinstance(notice_reference, dict):
                notice_reference = x509.NoticeReference(
                    organization=force_text(notice_reference.get('organization', '')),
                    notice_numbers=[int(i) for i in notice_reference.get('notice_numbers', [])]
                )
            elif notice_reference is None:
                pass  # extra branch to ensure test coverage
            elif isinstance(notice_reference, x509.NoticeReference):
                pass  # extra branch to ensure test coverage
            else:
                raise ValueError('NoticeReference must be either None, a dict or an x509.NoticeReference')

            return x509.UserNotice(explicit_text=explicit_text, notice_reference=notice_reference)
        raise ValueError('PolicyQualifier must be string, dict or x509.UserNotice') 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:25,代码来源:extensions.py

示例2: test_constructor

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import NoticeReference [as 别名]
def test_constructor(self):
        # just some constructors that are otherwise not called
        pi = PolicyInformation()
        self.assertIsNone(pi.policy_identifier)
        self.assertIsNone(pi.policy_qualifiers)

        pi = PolicyInformation({
            'policy_identifier': '1.2.3',
            'policy_qualifiers': [
                x509.UserNotice(notice_reference=None, explicit_text='foobar'),
            ],
        })
        # todo: test pi

        pi = PolicyInformation({
            'policy_identifier': '1.2.3',
            'policy_qualifiers': [{
                'notice_reference': x509.NoticeReference(organization='foobar', notice_numbers=[1]),
            }],
        })
        # todo: test pi 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:23,代码来源:tests_extensions.py

示例3: _decode_user_notice

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import NoticeReference [as 别名]
def _decode_user_notice(backend, un):
    explicit_text = None
    notice_reference = None

    if un.exptext != backend._ffi.NULL:
        explicit_text = backend._asn1_string_to_utf8(un.exptext)

    if un.noticeref != backend._ffi.NULL:
        organization = backend._asn1_string_to_utf8(un.noticeref.organization)

        num = backend._lib.sk_ASN1_INTEGER_num(
            un.noticeref.noticenos
        )
        notice_numbers = []
        for i in range(num):
            asn1_int = backend._lib.sk_ASN1_INTEGER_value(
                un.noticeref.noticenos, i
            )
            notice_num = backend._asn1_integer_to_int(asn1_int)
            notice_numbers.append(notice_num)

        notice_reference = x509.NoticeReference(
            organization, notice_numbers
        )

    return x509.UserNotice(notice_reference, explicit_text) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:28,代码来源:x509.py

示例4: _decode_user_notice

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import NoticeReference [as 别名]
def _decode_user_notice(backend, un):
    explicit_text = None
    notice_reference = None

    if un.exptext != backend._ffi.NULL:
        explicit_text = _asn1_string_to_utf8(backend, un.exptext)

    if un.noticeref != backend._ffi.NULL:
        organization = _asn1_string_to_utf8(
            backend, un.noticeref.organization
        )

        num = backend._lib.sk_ASN1_INTEGER_num(
            un.noticeref.noticenos
        )
        notice_numbers = []
        for i in range(num):
            asn1_int = backend._lib.sk_ASN1_INTEGER_value(
                un.noticeref.noticenos, i
            )
            notice_num = _asn1_integer_to_int(backend, asn1_int)
            notice_numbers.append(notice_num)

        notice_reference = x509.NoticeReference(
            organization, notice_numbers
        )

    return x509.UserNotice(notice_reference, explicit_text) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:30,代码来源:decode_asn1.py

示例5: test_constructor_errors

# 需要导入模块: from cryptography import x509 [as 别名]
# 或者: from cryptography.x509 import NoticeReference [as 别名]
def test_constructor_errors(self):
        with self.assertRaisesRegex(
                ValueError, r'^PolicyInformation data must be either x509.PolicyInformation or dict$'):
            PolicyInformation(True)

        with self.assertRaisesRegex(ValueError, r'^PolicyQualifier must be string, dict or x509.UserNotice$'):
            PolicyInformation({'policy_identifier': '1.2.3', 'policy_qualifiers': [True]})

        with self.assertRaisesRegex(
                ValueError, r'^NoticeReference must be either None, a dict or an x509.NoticeReference$'):
            PolicyInformation({'policy_identifier': '1.2.3', 'policy_qualifiers': [{
                'notice_reference': True,
            }]}) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:15,代码来源:tests_extensions.py


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