HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/ipapython/__pycache__/kerberos.cpython-36.pyc
3

�d[e��@sldZddlZddlZddlmZmZejr.eZej	d�Z
ej	d�Zddd�Zdd	�Z
ejGd
d�d��ZdS)
zC
classes/utils for Kerberos principal name validation/manipulation
�N)�
escape_seq�unescape_seqz(?<!\\)@z(?<!\\)/cCs`tj|�}t|�dkrtd��|d}y|d}Wn$tk
rV|dkrNdn|}YnX||fS)aS
    split principal to the <principal_name>, <realm> components

    :param principal: unicode representation of principal
    :param realm: if not None, replace the parsed realm with the specified one

    :returns: tuple containing the principal name and realm
        realm will be `None` if no realm was found in the input string
    �z)Principal is not in <name>@<realm> formatr�N)�REALM_SPLIT_RE�split�len�
ValueError�
IndexError)�	principal�realmZrealm_and_name�principal_name�parsed_realm�r�/usr/lib/python3.6/kerberos.py�parse_princ_name_and_realms

rcCsttj|��S)a�
    Split principal name (without realm) into the components

    NOTE: operates on the following RFC 1510 types:
        * NT-PRINCIPAL
        * NT-SRV-INST
        * NT-SRV-HST

    Enterprise principals (NT-ENTERPRISE, see RFC 6806) are also handled

    :param principal_name: unicode representation of principal name
    :returns: tuple of individual components (i.e. primary name for
    NT-PRINCIPAL and NT-ENTERPRISE, primary name and instance for others)
    )�tuple�COMPONENT_SPLIT_REr)r
rrr�split_principal_name-src@s�eZdZdZd)dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zd*dd�Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd ��Ze
d!d"��Ze
d#d$��Zd%d&�Zd'd(�ZdS)+�	PrincipalzJ
    Container for the principal name and realm according to RFC 1510
    NcCsvt|t�rtdj|���nXt|t�r:|j||�\|_|_n8t|t�rb|j|_|dkrZ|jn||_nt	|�|_||_dS)Nz1Cannot create a principal object from bytes: {!r})
�
isinstance�bytes�	TypeError�format�str�_parse_from_text�
componentsrrr)�selfrrrrr�__init__Ds




zPrincipal.__init__cCs&t|t�sdS|j|jko$|j|jkS)NF)rrrr)r�otherrrr�__eq__Vs
zPrincipal.__eq__cCs|j|�S)N)r )rrrrr�__ne__]szPrincipal.__ne__cCst|�t|�kS)N)�unicode)rrrrr�__lt__`szPrincipal.__lt__cCs|j|�p|j|�S)N)r#r )rrrrr�__le__cszPrincipal.__le__cCs|j|�S)N)r$)rrrrr�__gt__fszPrincipal.__gt__cCs|j|�p|j|�S)N)r%r )rrrrr�__ge__iszPrincipal.__ge__cCst|j|jf�S)N)�hashrr)rrrr�__hash__lszPrincipal.__hash__cCsLt||d�\}}td|�\}|dk	r0td|�\}t|�}td|��}||fS)ae
        parse individual principal name components from the string
        representation of the principal. This is done in three steps:
            1.) split the string at the unescaped '@'
            2.) unescape any leftover '\@' sequences
            3.) split the primary at the unescaped '/'
            4.) unescape leftover '\/'
        :param principal: unicode representation of the principal name
        :param realm: if not None, this realm name will be used instead of the
            one parsed from `principal`

        :returns: tuple containing the principal name components and realm
        )r�@N�/)r*)rrr)rrrr
r�name_componentsrrrroszPrincipal._parse_from_textcCst|j�dkS)Nr)rr)rrrr�is_user�szPrincipal.is_usercCs|jod|jdkS)Nr)r)r,r)rrrr�
is_enterprise�szPrincipal.is_enterprisecCst|j�dkS)Nr)rr)rrrr�
is_service�szPrincipal.is_servicecCs"|jo t|j�dko |jddkS)Nrr�host)r.rr)rrrr�is_host�szPrincipal.is_hostcCs|jr|jdStd��dS)Nrz<User name is defined only for user and enterprise principals)r,rr	)rrrr�username�s
zPrincipal.usernamecCs"|jstd��|jdjd�dS)Nz*Only enterprise principals have UPN suffixrr)r)r-r	rr)rrrr�
upn_suffix�szPrincipal.upn_suffixcCs|jp
|jstd��|jdS)Nz3hostname is defined for host and service principalsr���)r0r.r	r)rrrr�hostname�szPrincipal.hostnamecCs4|jstd��djdd�td|jdd���D��S)Nz4Only service principals have meaningful service namer*css|]
}|VqdS)Nr)�.0�crrr�	<genexpr>�sz)Principal.service_name.<locals>.<genexpr>r)r*r3)r.r	�joinrr)rrrr�service_name�szPrincipal.service_namecCsNtd|j��}td|��}dj|�}|jdk	rJtd|j�\}dj||g�}|S)zz
        return the unicode representation of principal

        works in reverse of the `from_text` class method
        r*r)N)r*)r))rrr8r)rr+Zprincipal_stringrrrr�__str__�s

zPrincipal.__str__cCsdj|j|�S)Nz"{0.__module__}.{0.__name__}('{1}'))r�	__class__)rrrr�__repr__�szPrincipal.__repr__)N)N)�__name__�
__module__�__qualname__�__doc__rr r!r#r$r%r&r(r�propertyr,r-r.r0r1r2r4r9r:r<rrrrr?s(

r)N)r@�reZsixZipapython.ipautilrrZPY3rr"�compilerrrrZpython_2_unicode_compatiblerrrrr�<module>s