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/lib64/python3.9/site-packages/gssapi/__pycache__/names.cpython-39.pyc
a

��_/3�@s�ddlZddlmZddlmZddlmZddlmZej	rPddl
mZmZnddl
mZmZe�d�Ze�d�ZGd	d
�d
ej�ZGdd�de�ZdS)
�N)�names)�NameType)�named_tuples)�_utils)�MutableMapping�IterableZrfc6680Zrfc6680_comp_oidcs�eZdZdZdZd)�fdd�	Zd*dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
edd��Zdd�Z
dd�Zdd�Zd+dd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zed%d&��Zed'd(��Z�ZS),�Namea�A GSSAPI Name

    This class represents a GSSAPI name which may be used with and/or returned
    by other GSSAPI methods.

    It inherits from the low-level GSSAPI :class:`~gssapi.raw.names.Name`
    class, and thus may used with both low-level and high-level API methods.

    This class may be pickled and unpickled, as well as copied.

    The :func:`str` and :func:`bytes` methods may be used to retrieve the
    text of the name.

    Note:
        Name strings will be automatically converted to and from unicode
        strings as appropriate.  If a method is listed as returning a
        :class:`str` object, it will return a unicode string.

        The encoding used will be python-gssapi's current encoding, which
        defaults to UTF-8.
    �	_attr_objNFcs�|dur||rltdurtd��tdur\t�|tj�}tj|dd�}|jtjkrjt�|tj	�}qzt�|tj	�}q�t�|tj	�}n8t
|tj�r�|}n&t
|tj
�r�|�t���}t�||�}tt|��||�S)N�SYour GSSAPI implementation does not support RFC 6680 (the GSSAPI naming extensions)T��	name_type)�
rname_rfc6680�NotImplementedError�rname_rfc6680_comp_oid�rnameZimport_namerZcomposite_export�display_namer�export�
isinstancer�six�	text_type�encoder�
_get_encoding�super�__new__)�cls�baser�token�	composite�	base_nameZ
displ_name��	__class__��2/usr/lib64/python3.9/site-packages/gssapi/names.pyr+s*��zName.__new__cCstdurt|�|_nd|_dS)ag
        The constructor can be used to "import" a name from a human readable
        representation, or from a token, and can also be used to convert a
        low-level :class:`gssapi.raw.names.Name` object into a high-level
        object.

        If a :class:`~gssapi.raw.names.Name` object from the low-level API
        is passed as the `base` argument, it will be converted into a
        high-level object.

        If the `token` argument is used, the name will be imported using
        the token.  If the token was exported as a composite token,
        pass `composite=True`.

        Otherwise, a new name will be created, using the `base` argument as
        the human-readable string and the `name_type` argument to denote the
        name type.

        Raises:
            BadNameTypeError
            BadNameError
            BadMechanismError
        N)r
�_NameAttributeMappingr	)�selfrrrrr!r!r"�__init__Osz
Name.__init__cCs*tttj�rt|��t���S|��SdS�N)	�
issubclass�strrr�bytes�decoderr�	__bytes__�r$r!r!r"�__str__mszName.__str__cCs|���t���Sr&)r+r*rrr,r!r!r"�__unicode__uszName.__unicode__cCstj|dd�jS)NFr)rr�namer,r!r!r"r+yszName.__bytes__cCs&tdurtd��t�||��t���S)aU
        Display this name as the given name type.

        This method attempts to display the current :class:`Name`
        using the syntax of the given :class:`NameType`, if possible.

        Warning:

            In MIT krb5 versions below 1.13.3, this method can segfault if
            the name was not *originally* created with a `name_type` that was
            not ``None`` (even in cases when a ``name_type``
            is later "added", such as via :meth:`canonicalize`).
            **Do not use this method unless you are sure the above
            conditions can never happen in your code.**

        Warning:

            In addition to the above warning, current versions of MIT krb5 do
            not actually fully implement this method, and it may return
            incorrect results in the case of canonicalized names.

        :requires-ext:`rfc6680`

        Args:
            name_type (OID): the :class:`NameType` to use to display the given
                name

        Returns:
            str: the displayed name

        Raises:
            OperationUnavailableError
        Nr
)r
rZdisplay_name_extr*rr)r$rr!r!r"�
display_as}s
#�zName.display_ascCstj|dd�jS)z"The :class:`NameType` of this nameTr)rrrr,r!r!r"r�szName.name_typecCs t|tj�stSt�||�SdSr&)rrr�NotImplementedZcompare_name�r$�otherr!r!r"�__eq__�szName.__eq__cCs|�|�Sr&)r4r2r!r!r"�__ne__�szName.__ne__cCs tj|dd�}dj|j|jd�S)NTrzName({name}, {name_type}))r/r)rr�formatr/r)r$Zdisp_resr!r!r"�__repr__�s�z
Name.__repr__cCs,|rtdurtd��t�|�St�|�SdS)a�Export this name as a token.

        This method exports the name into a byte string which can then be
        imported by using the `token` argument of the constructor.

        Args:
            composite (bool): whether or not use to a composite token --
                :requires-ext:`rfc6680`

        Returns:
            bytes: the exported name in token form

        Raises:
            MechanismNameRequiredError
            BadNameTypeError
            BadNameError
        Nr
)r
rZexport_name_compositerZexport_name)r$rr!r!r"r�s

zName.exportcCst|�t�||��S)a�Canonicalize a name with respect to a mechanism.

        This method returns a new :class:`Name` that is canonicalized according
        to the given mechanism.

        Args:
            mech (OID): the :class:`MechType` to use

        Returns:
            Name: the canonicalized name

        Raises:
            BadMechanismError
            BadNameTypeError
            BadNameError
        )�typerZcanonicalize_name)r$�mechr!r!r"�canonicalize�szName.canonicalizecCst|�t�|��Sr&�r8rZduplicate_namer,r!r!r"�__copy__�sz
Name.__copy__cCst|�t�|��Sr&r;)r$�memor!r!r"�__deepcopy__�szName.__deepcopy__cKsFtdurtd��|sd}nd}|�d|�}|�d|�}tj|||d�S)a�Inspect this name for information.

        This method inspects the name for information.

        If no keyword arguments are passed, all available information
        is returned.  Otherwise, only the keyword arguments that
        are passed and set to `True` are returned.

        Args:
            mech_name (bool): get whether this is a mechanism name,
                and, if so, the associated mechanism
            attrs (bool): get the attributes names for this name

        Returns:
            InquireNameResult: the results of the inquiry, with unused
                fields set to None

        Raises:
            GSSError
        Nr
TF�attrs�	mech_name)r@r?)r
r�getZinquire_name)r$�kwargsZdefault_valr?r@r!r!r"�_inquire�s�z
Name._inquirecCs|jdd�jS)zWWhether or not this name is a mechanism name
        (:requires-ext:`rfc6680`)
        T�r@)rC�is_mech_namer,r!r!r"rEszName.is_mech_namecCs|jdd�jS)zJThe mechanism associated with this name (:requires-ext:`rfc6680`)
        TrD)rCr9r,r!r!r"r9 sz	Name.mechcCs|jdurtd��|jS)a�The attributes of this name (:requires-ext:`rfc6680`)

        The attributes are presenting in the form of a
        :class:`~collections.MutableMapping` (a dict-like object).

        Retrieved values will always be in the form of :class:`frozensets`.

        When assigning values, if iterables are used, they be considered to be
        the set of values for the given attribute.  If a non-iterable is used,
        it will be considered a single value, and automatically wrapped in an
        iterable.

        Note:
            String types (includes :class:`bytes`) are not considered to
            be iterables in this case.
        Nr
)r	rr,r!r!r"�
attributes&s
zName.attributes)NNNF)NNNF)F)�__name__�
__module__�__qualname__�__doc__�	__slots__rr%r-r.r+r0�propertyrr4r5r7rr:r<r>rCrEr9rF�
__classcell__r!r!rr"rs4�$
*

&

rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)r#z6Provides dict-like access to RFC 6680 Name attributes.cCs
||_dSr&)�_name)r$r/r!r!r"r%Csz_NameAttributeMapping.__init__cCsHt|tj�r|�t���}t�|j|�}t	�
t|j�t|j
�|j|j�Sr&)rrrrrrr
Zget_name_attributerN�tuples�GetNameAttributeResult�	frozenset�valuesZdisplay_valuesZ
authenticated�complete)r$�key�resr!r!r"�__getitem__Fs�z!_NameAttributeMapping.__getitem__cCs�t|tj�r|�t���}t�|j|�t|t	j
�rB|j}|j}n,t|t
�rjt|�dkrj|d}|d}nd}t|tjtf�s�t|t�s�|g}tj|j|||d�dS)N��rF)rS)rrrrrrr
�delete_name_attributerNrOrPrSrR�tuple�lenZstring_typesr)rZset_name_attribute)r$rT�valuerSr!r!r"�__setitem__Ps"
��z!_NameAttributeMapping.__setitem__cCs,t|tj�r|�t���}t�|j|�dSr&)	rrrrrrr
rYrN)r$rTr!r!r"�__delitem__hsz!_NameAttributeMapping.__delitem__cCst|jjdd�j�S�NT)r?)�iterrNrCr?r,r!r!r"�__iter__nsz_NameAttributeMapping.__iter__cCst|jjdd�j�Sr_)r[rNrCr?r,r!r!r"�__len__qsz_NameAttributeMapping.__len__N)
rGrHrIrJr%rVr]r^rarbr!r!r!r"r#@s
r#)rZ
gssapi.rawrrrrrOZgssapirZPY2�collectionsrr�collections.abcZimport_gssapi_extensionr
rrr#r!r!r!r"�<module>s

0