Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/cryptography/x509/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/cryptography/x509/__pycache__/name.cpython-35.pyc



���]��@s�ddlmZmZmZddlZddlmZddlmZm	Z	Gdd�de
�ZGdd�de
�ZGd	d
�d
e
�Z
dS)�)�absolute_import�division�print_functionN)�utils)�NameOID�ObjectIdentifierc@sjeZdZdd�Zejd�Zejd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
S)�
NameAttributecCs�t|t�std��t|tj�s9td��|tjkrot|jd��dkrot	d��||_
||_dS)Nz2oid argument must be an ObjectIdentifier instance.z#value argument must be a text type.�utf8�z/Country name must be a 2 character country code)�
isinstancer�	TypeError�six�	text_typerZCOUNTRY_NAME�len�encode�
ValueError�_oid�_value)�self�oid�value�r�I/opt/alt/python35/lib64/python3.5/site-packages/cryptography/x509/name.py�__init__s		*		zNameAttribute.__init__rrcCs5t|t�stS|j|jko4|j|jkS)N)rr�NotImplementedrr)r�otherrrr�__eq__$szNameAttribute.__eq__cCs||kS)Nr)rrrrr�__ne__-szNameAttribute.__ne__cCst|j|jf�S)N)�hashrr)rrrr�__hash__0szNameAttribute.__hash__cCs
dj|�S)Nz/<NameAttribute(oid={0.oid}, value={0.value!r})>)�format)rrrr�__repr__3szNameAttribute.__repr__N)�__name__�
__module__�__qualname__rrZread_only_propertyrrrrrr!rrrrr
s	rc@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�RelativeDistinguishedNamecCsPt|�}|std��tdd�|D��sCtd��||_dS)Nz-a relative distinguished name cannot be emptycss|]}t|t�VqdS)N)rr)�.0�xrrr�	<genexpr><sz5RelativeDistinguishedName.__init__.<locals>.<genexpr>z/attributes must be an iterable of NameAttribute)�	frozensetr�allr�_attributes)r�
attributesrrrr8sz"RelativeDistinguishedName.__init__cs�fdd�|D�S)Ncs%g|]}|j�kr|�qSr)r)r&�i)rrr�
<listcomp>Bs	zDRelativeDistinguishedName.get_attributes_for_oid.<locals>.<listcomp>r)rrr)rr�get_attributes_for_oidAsz0RelativeDistinguishedName.get_attributes_for_oidcCs#t|t�stS|j|jkS)N)rr%rr+)rrrrrrDsz RelativeDistinguishedName.__eq__cCs||kS)Nr)rrrrrrJsz RelativeDistinguishedName.__ne__cCs
t|j�S)N)rr+)rrrrrMsz"RelativeDistinguishedName.__hash__cCs
t|j�S)N)�iterr+)rrrr�__iter__Psz"RelativeDistinguishedName.__iter__cCs
t|j�S)N)rr+)rrrr�__len__Ssz!RelativeDistinguishedName.__len__cCsdjt|��S)Nz"<RelativeDistinguishedName({0!r})>)r �list)rrrrr!Vsz"RelativeDistinguishedName.__repr__N)r"r#r$rr/rrrr1r2r!rrrrr%7s	r%c@s�eZdZdd�Zdd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�NamecCsst|�}tdd�|D��r>dd�|D�|_n1tdd�|D��rc||_ntd��dS)Ncss|]}t|t�VqdS)N)rr)r&r'rrrr(]sz Name.__init__.<locals>.<genexpr>cSsg|]}t|g��qSr)r%)r&r'rrrr._s	z!Name.__init__.<locals>.<listcomp>css|]}t|t�VqdS)N)rr%)r&r'rrrr(aszNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r3r*r+r)rr,rrrr[sz
Name.__init__cs�fdd�|D�S)Ncs%g|]}|j�kr|�qSr)r)r&r-)rrrr.js	z/Name.get_attributes_for_oid.<locals>.<listcomp>r)rrr)rrr/iszName.get_attributes_for_oidcCs|jS)N)r+)rrrr�rdnslsz	Name.rdnscCs
|j|�S)N)Zx509_name_bytes)r�backendrrr�public_bytespszName.public_bytescCs#t|t�stS|j|jkS)N)rr4rr+)rrrrrrsszName.__eq__cCs||kS)Nr)rrrrrryszName.__ne__cCstt|j��S)N)r�tupler+)rrrrr|sz
Name.__hash__ccs.x'|jD]}x|D]}|VqWq
WdS)N)r+)r�rdnZavarrrr1�s
z
Name.__iter__cCstdd�|jD��S)Ncss|]}t|�VqdS)N)r)r&r9rrrr(�szName.__len__.<locals>.<genexpr>)�sumr+)rrrrr2�szName.__len__cCsdjt|��S)Nz
<Name({0!r})>)r r3)rrrrr!�sz
Name.__repr__N)r"r#r$rr/�propertyr5r7rrrr1r2r!rrrrr4Zsr4)�
__future__rrrr
�cryptographyrZcryptography.x509.oidrr�objectrr%r4rrrr�<module>s*#