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


Python name.Name方法代码示例

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


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

示例1: __init__

# 需要导入模块: from cryptography.x509 import name [as 别名]
# 或者: from cryptography.x509.name import Name [as 别名]
def __init__(self, value):
        if not isinstance(value, six.text_type):
            raise TypeError("value must be a unicode string")

        name, address = parseaddr(value)
        parts = address.split(u"@")
        if name or not address:
            # parseaddr has found a name (e.g. Name <email>) or the entire
            # value is an empty string.
            raise ValueError("Invalid rfc822name value")
        elif len(parts) == 1:
            # Single label email name. This is valid for local delivery.
            # No IDNA encoding needed since there is no domain component.
            encoded = address.encode("ascii")
        else:
            # A normal email of the form [email protected] Let's attempt to
            # encode the domain component and reconstruct the address.
            encoded = parts[0].encode("ascii") + b"@" + idna.encode(parts[1])

        self._value = value
        self._encoded = encoded 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:23,代码来源:general_name.py

示例2: __init__

# 需要导入模块: from cryptography.x509 import name [as 别名]
# 或者: from cryptography.x509.name import Name [as 别名]
def __init__(self, value):
        if isinstance(value, six.text_type):
            try:
                value.encode("ascii")
            except UnicodeEncodeError:
                value = self._idna_encode(value)
                warnings.warn(
                    "RFC822Name values should be passed as an A-label string. "
                    "This means unicode characters should be encoded via "
                    "idna. Support for passing unicode strings (aka U-label) "
                    " will be removed in a future version.",
                    utils.DeprecatedIn21,
                    stacklevel=2,
                )
        else:
            raise TypeError("value must be string")

        name, address = parseaddr(value)
        if name or not address:
            # parseaddr has found a name (e.g. Name <email>) or the entire
            # value is an empty string.
            raise ValueError("Invalid rfc822name value")

        self._value = value 
开发者ID:aws-quickstart,项目名称:quickstart-git2s3,代码行数:26,代码来源:general_name.py

示例3: subject_name

# 需要导入模块: from cryptography.x509 import name [as 别名]
# 或者: from cryptography.x509.name import Name [as 别名]
def subject_name(self, name):
        """
        Sets the certificate requestor's distinguished name.
        """
        if not isinstance(name, Name):
            raise TypeError('Expecting x509.Name object.')
        if self._subject_name is not None:
            raise ValueError('The subject name may only be set once.')
        return CertificateSigningRequestBuilder(name, self._extensions) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:11,代码来源:base.py

示例4: issuer_name

# 需要导入模块: from cryptography.x509 import name [as 别名]
# 或者: from cryptography.x509.name import Name [as 别名]
def issuer_name(self, name):
        """
        Sets the CA's distinguished name.
        """
        if not isinstance(name, Name):
            raise TypeError('Expecting x509.Name object.')
        if self._issuer_name is not None:
            raise ValueError('The issuer name may only be set once.')
        return CertificateBuilder(
            name, self._subject_name, self._public_key,
            self._serial_number, self._not_valid_before,
            self._not_valid_after, self._extensions
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:15,代码来源:base.py

示例5: issuer_name

# 需要导入模块: from cryptography.x509 import name [as 别名]
# 或者: from cryptography.x509.name import Name [as 别名]
def issuer_name(self, issuer_name):
        if not isinstance(issuer_name, Name):
            raise TypeError('Expecting x509.Name object.')
        if self._issuer_name is not None:
            raise ValueError('The issuer name may only be set once.')
        return CertificateRevocationListBuilder(
            issuer_name, self._last_update, self._next_update,
            self._extensions, self._revoked_certificates
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:11,代码来源:base.py


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