HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/ipapython/__pycache__/kerberos.cpython-39.opt-1.pyc
a

}�f��@sldZddlZddlZddlmZmZejr.eZe�	d�Z
e�	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^t�|�}t|�dkrtd��|d}z|d}Wn"tyT|durLdn|}Yn0||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�6/usr/lib/python3.9/site-packages/ipapython/kerberos.py�parse_princ_name_and_realms

�rcCstt�|��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�rtd�|���nXt|t�r:|�||�\|_|_n8t|t�rb|j|_|durZ|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|�|�S�N)r!rrrr�__ne__]szPrincipal.__ne__cCst|�t|�kSr")�unicoderrrr�__lt__`szPrincipal.__lt__cCs|�|�p|�|�Sr")r%r!rrrr�__le__cszPrincipal.__le__cCs|�|�Sr")r&rrrr�__gt__fszPrincipal.__gt__cCs|�|�p|�|�Sr")r'r!rrrr�__ge__iszPrincipal.__ge__cCst|j|jf�Sr")�hashrr�rrrr�__hash__lszPrincipal.__hash__cCsPt||d�\}}td|�\}|dur0td|�\}t|�}tdg|�R�}||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�/)rrr)rrrr
r�name_componentsrrrros�
zPrincipal._parse_from_textcCst|j�dkS�Nr�rrr*rrr�is_user�szPrincipal.is_usercCs|jod|jdvS)Nr,r)r1rr*rrr�
is_enterprise�szPrincipal.is_enterprisecCst|j�dkSr/r0r*rrr�
is_service�szPrincipal.is_servicecCs"|jo t|j�dko |jddkS)Nrr�host)r3rrr*rrr�is_host�s�zPrincipal.is_hostcCs|jr|jdStd��dS)Nrz<User name is defined only for user and enterprise principals)r1rr	r*rrr�username�s

�zPrincipal.usernamecCs"|jstd��|jd�d�dS)Nz*Only enterprise principals have UPN suffixrr,r)r2r	rrr*rrr�
upn_suffix�szPrincipal.upn_suffixcCs|js|jstd��|jdS)Nz3hostname is defined for host and service principals���)r5r3r	rr*rrr�hostname�s
�zPrincipal.hostnamecCs8|jstd��d�dd�tdg|jdd��R�D��S)Nz4Only service principals have meaningful service namer-css|]
}|VqdSr"r)�.0�crrr�	<genexpr>��z)Principal.service_name.<locals>.<genexpr>r8)r3r	�joinrrr*rrr�service_name�s
�zPrincipal.service_namecCsVtdg|j�R�}tdg|�R�}d�|�}|jdurRtd|j�\}d�||g�}|S)zz
        return the unicode representation of principal

        works in reverse of the `from_text` class method
        r-r,N)rrr>r)rr.Zprincipal_stringrrrr�__str__�s

zPrincipal.__str__cCsd�|j|�S)Nz"{0.__module__}.{0.__name__}('{1}'))r�	__class__r*rrr�__repr__�s�zPrincipal.__repr__)N)N)�__name__�
__module__�__qualname__�__doc__rr!r#r%r&r'r(r+r�propertyr1r2r3r5r6r7r9r?r@rBrrrrr?s8









r)N)rF�reZsixZipapython.ipautilrrZPY3rr$�compilerrrrZpython_2_unicode_compatiblerrrrr�<module>s