B \` @sddlmZmZmZddlmZddlZddlmZddl m Z m Z GdddeZ e dd e DZeZe je je je je je je je je je je je jiZGd d d eZGd d d eZGdddeZdS))absolute_importdivisionprint_function)EnumN)utils)NameOIDObjectIdentifierc@s4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) _ASN1Type N) __name__ __module__ __qualname__ UTF8StringZ NumericStringPrintableStringZ T61String IA5StringZUTCTimeZGeneralizedTimeZ VisibleStringZUniversalStringZ BMPStringrrI/opt/alt/python37/lib64/python3.7/site-packages/cryptography/x509/name.pyr sr ccs|]}|j|fVqdS)N)value).0irrr src@sLeZdZefddZedZedZddZ ddZ d d Z d d Z d S) NameAttributecCst|tstdt|tjs&td|tjks:|tjkrTt| ddkrTt dt|dkrht d|t kr~t |tj}t|tstd||_||_||_dS) Nz2oid argument must be an ObjectIdentifier instance.z#value argument must be a text type.utf8z/Country name must be a 2 character country coderzValue cannot be an empty stringz%_type must be from the _ASN1Type enum) isinstancer TypeErrorsixZ text_typer COUNTRY_NAMEJURISDICTION_COUNTRY_NAMElenencode ValueError _SENTINEL_NAMEOID_DEFAULT_TYPEgetr r_oid_value_type)selfoidrr0rrr__init__)s(      zNameAttribute.__init__r.r/cCs&t|tstS|j|jko$|j|jkS)N)r#r NotImplementedr2r)r1otherrrr__eq__Ss  zNameAttribute.__eq__cCs ||k S)Nr)r1r5rrr__ne__\szNameAttribute.__ne__cCst|j|jfS)N)hashr2r)r1rrr__hash___szNameAttribute.__hash__cCs d|S)Nz/)format)r1rrr__repr__bszNameAttribute.__repr__N) rrrr+r3rZread_only_propertyr2rr6r7r9r;rrrrr (s '   r c@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)RelativeDistinguishedNamecCs\t|}|stdtdd|Ds.td||_t||_t|jt|krXtddS)Nz-a relative distinguished name cannot be emptycss|]}t|tVqdS)N)r#r )rxrrrrksz5RelativeDistinguishedName.__init__..z/attributes must be an iterable of NameAttributez$duplicate attributes are not allowed)listr*allr$ _attributes frozenset_attribute_setr()r1 attributesrrrr3gs z"RelativeDistinguishedName.__init__csfdd|DS)Ncsg|]}|jkr|qSr)r2)rr)r2rr vszDRelativeDistinguishedName.get_attributes_for_oid..r)r1r2r)r2rget_attributes_for_oidusz0RelativeDistinguishedName.get_attributes_for_oidcCst|tstS|j|jkS)N)r#r<r4rB)r1r5rrrr6xs z RelativeDistinguishedName.__eq__cCs ||k S)Nr)r1r5rrrr7~sz RelativeDistinguishedName.__ne__cCs t|jS)N)r8rB)r1rrrr9sz"RelativeDistinguishedName.__hash__cCs t|jS)N)iterr@)r1rrr__iter__sz"RelativeDistinguishedName.__iter__cCs t|jS)N)r(r@)r1rrr__len__sz!RelativeDistinguishedName.__len__cCsdt|S)Nz")r:r>)r1rrrr;sz"RelativeDistinguishedName.__repr__N) rrrr3rEr6r7r9rGrHr;rrrrr<fsr<c@s`eZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dS)NamecCsRt|}tdd|Dr,dd|D|_n"tdd|DrF||_ntddS)Ncss|]}t|tVqdS)N)r#r )rr=rrrrsz Name.__init__..cSsg|]}t|gqSr)r<)rr=rrrrDsz!Name.__init__..css|]}t|tVqdS)N)r#r<)rr=rrrrszNattributes must be a list of NameAttribute or a list RelativeDistinguishedName)r>r?r@r$)r1rCrrrr3sz Name.__init__csfdd|DS)Ncsg|]}|jkr|qSr)r2)rr)r2rrrDsz/Name.get_attributes_for_oid..r)r1r2r)r2rrEszName.get_attributes_for_oidcCs|jS)N)r@)r1rrrrdnssz Name.rdnscCs ||S)N)Zx509_name_bytes)r1Zbackendrrr public_bytesszName.public_bytescCst|tstS|j|jkS)N)r#rIr4r@)r1r5rrrr6s z Name.__eq__cCs ||k S)Nr)r1r5rrrr7sz Name.__ne__cCstt|jS)N)r8tupler@)r1rrrr9sz Name.__hash__ccs(x"|jD]}x|D] }|VqWqWdS)N)r@)r1rdnZavarrrrGs  z Name.__iter__cCstdd|jDS)Ncss|]}t|VqdS)N)r()rrMrrrrszName.__len__..)sumr@)r1rrrrHsz Name.__len__cCsdt|S)Nz )r:r>)r1rrrr;sz Name.__repr__N)rrrr3rEpropertyrJrKr6r7r9rGrHr;rrrrrIs rI)Z __future__rrrenumrr%Z cryptographyrZcryptography.x509.oidrrr dictZ_ASN1_TYPE_TO_ENUMobjectr+r&rr'Z SERIAL_NUMBERZ DN_QUALIFIERZ EMAIL_ADDRESSrZDOMAIN_COMPONENTr,r r<rIrrrrs     >(