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: //lib64/python3.6/site-packages/gssapi/__pycache__/creds.cpython-36.opt-1.pyc
3

�O[�@�@sjddlmZddlmZddlmZmZddlm	Z	ed�Z
ed�Zed�Zed�Z
Gd	d
�d
ej�ZdS)�)�creds)�named_tuples)�import_gssapi_extension�_encode_dict)�namesZcred_imp_expZs4uZ
cred_storeZrfc5588cs�eZdZdZfZd!�fdd�	Zedd��Zedd	��Zed
d��Z	edd
��Z
ed"dd��Zd#dd�Z
d$dd�Zd%dd�Zd&dd�Zd'dd�Zdd�Zdd �Z�ZS)(�Credentialsa<GSSAPI Credentials

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

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

    If your implementation of GSSAPI supports the credentials import-export
    extension, you may pickle and unpickle this object.

    The constructor either acquires or imports a set of GSSAPI
    credentials.

    If the `base` argument is used, an existing
    :class:`~gssapi.raw.creds.Cred` object from the low-level API is
    converted into a high-level object.

    If the `token` argument is used, the credentials
    are imported using the token, if the credentials import-export
    extension is supported (:requires-ext:`cred_imp_exp`).

    Otherwise, the credentials are acquired as per the
    :meth:`acquire` method.

    Raises:
        BadMechanismError
        BadNameTypeError
        BadNameError
        ExpiredCredentialsError
        MissingCredentialsError
    N�bothc
s^|dk	r|}n>|dk	r2tdkr&td��tj|�}n|j|||||d�}	|	j}tt|�j||�S)NzWYour GSSAPI implementation does not have support for importing and exporting creditials)�store)�
rcred_imp_exp�NotImplementedErrorZimport_cred�acquirer�superr�__new__)
�cls�base�token�name�lifetime�mechs�usager	Z
base_creds�res)�	__class__��/usr/lib64/python3.6/creds.pyr1szCredentials.__new__cCs|jddddd�jS)z.Get the name associated with these credentialsTF)rrrr)�inquirer)�selfrrrrEszCredentials.namecCs|jddddd�jS)z/Get the remaining lifetime of these credentialsFT)rrrr)rr)rrrrrKszCredentials.lifetimecCs|jddddd�jS)z(Get the mechanisms for these credentialsFT)rrrr)rr)rrrrrQszCredentials.mechscCs|jddddd�jS)z>Get the usage (initiate, accept, or both) of these credentialsFT)rrrr)rr)rrrrrWszCredentials.usagecCs^|dkrtj||||�}n*tdkr*td��t|�}tj|||||�}tj||jd�|j	|j
�S)aAcquire GSSAPI credentials

        This method acquires credentials.  If the `store` argument is
        used, the credentials will be acquired from the given
        credential store (if supported).  Otherwise, the credentials are
        acquired from the default store.

        The credential store information is a dictionary containing
        mechanisms-specific keys and values pointing to a credential store
        or stores.

        Using a non-default store requires support for the credentials store
        extension.

        Args:
            name (Name): the name associated with the credentials,
                or None for the default name
            lifetime (int): the desired lifetime of the credentials, or None
                for indefinite
            mechs (list): the desired :class:`MechType` OIDs to be used
                with the credentials, or None for the default set
            usage (str): the usage for the credentials -- either 'both',
                'initiate', or 'accept'
            store (dict): the credential store information pointing to the
                credential store from which to acquire the credentials,
                or None for the default store (:requires-ext:`cred_store`)

        Returns:
            AcquireCredResult: the acquired credentials and information about
                them

        Raises:
            BadMechanismError
            BadNameTypeError
            BadNameError
            ExpiredCredentialsError
            MissingCredentialsError
        NzSYour GSSAPI implementation does not have support for manipulating credential stores)r)�rcredsZacquire_cred�rcred_cred_storerrZacquire_cred_from�tuplesZAcquireCredResultrrr)rrrrrr	rrrrr]s*
zCredentials.acquireFcCsZ|dkr*tdkrtd��tj|||||�Stdkr:td��t|�}tj||||||�SdS)a�Store these credentials into the given store

        This method stores the current credentials into the specified
        credentials store.  If the default store is used, support for
        :rfc:`5588` is required.  Otherwise, support for the credentials
        store extension is required.

        :requires-ext:`rfc5588` or :requires-ext:`cred_store`

        Args:
            store (dict): the store into which to store the credentials,
                or None for the default store.
            usage (str): the usage to store the credentials with -- either
                'both', 'initiate', or 'accept'
            mech (OID): the :class:`MechType` to associate with the
                stored credentials
            overwrite (bool): whether or not to overwrite existing credentials
                stored with the same name, etc
            set_default (bool): whether or not to set these credentials as
                the default credentials for the given store.

        Returns:
            StoreCredResult: the results of the credential storing operation

        Raises:
            GSSError
            ExpiredCredentialsError
            MissingCredentialsError
            OperationUnavailableError
            DuplicateCredentialsElementError
        Nz=Your GSSAPI implementation does not have support for RFC 5588z\Your GSSAPI implementation does not have support for manipulating credential stores directly)�
rcred_rfc5588rZ
store_credrrZstore_cred_into)rr	r�mechZ	overwriteZset_defaultrrrr	�s"
zCredentials.store�initiatecCs2tdkrtd��tj|||||�}t|�|jd�S)a�Impersonate a name using the current credentials

        This method acquires credentials by impersonating another
        name using the current credentials.

        :requires-ext:`s4u`

        Args:
            name (Name): the name to impersonate
            lifetime (int): the desired lifetime of the new credentials,
                or None for indefinite
            mechs (list): the desired :class:`MechType` OIDs for the new
                credentials
            usage (str): the desired usage for the new credentials -- either
                'both', 'initiate', or 'accept'.  Note that some mechanisms
                may only support 'initiate'.

        Returns:
            Credentials: the new credentials impersonating the given name
        Nz8Your GSSAPI implementation does not have support for S4U)r)�	rcred_s4urZacquire_cred_impersonate_name�typer)rrrrrrrrr�impersonate�szCredentials.impersonateTcCsDtj|||||�}|jdk	r*tj|j�}nd}tj||j|j|j	�S)a�Inspect these credentials for information

        This method inspects these credentials for information about them.

        Args:
            name (bool): get the name associated with the credentials
            lifetime (bool): get the remaining lifetime for the credentials
            usage (bool): get the usage for the credentials
            mechs (bool): get the mechanisms associated with the credentials

        Returns:
            InquireCredResult: the information about the credentials,
                with None used when the corresponding argument was False

        Raises:
            MissingCredentialsError
            InvalidCredentialsError
            ExpiredCredentialsError
        N)
rZinquire_credrr�NamerZInquireCredResultrrr)rrrrrr�res_namerrrr�s

zCredentials.inquirecCsFtj||||||�}|jdk	r,tj|j�}nd}tj||j|j|j	�S)a�Inspect these credentials for per-mechanism information

        This method inspects these credentials for per-mechanism information
        about them.

        Args:
            mech (OID): the mechanism for which to retrive the information
            name (bool): get the name associated with the credentials
            init_lifetime (bool): get the remaining initiate lifetime for
                the credentials
            accept_lifetime (bool): get the remaining accept lifetime for
                the credentials
            usage (bool): get the usage for the credentials

        Returns:
            InquireCredByMechResult: the information about the credentials,
                with None used when the corresponding argument was False
        N)
rZinquire_cred_by_mechrrr%rZInquireCredByMechResult�
init_lifetime�accept_lifetimer)rr rr'r(rrr&rrr�inquire_by_mech
s
zCredentials.inquire_by_mechc	Cs�|dk	r|dk	rtd��|dk	rPtdkr0td��t|�}tj|||||||�}nD|dk	r�tdkrhtd��tj|||||||�}ntj||||||�}t	|j
�S)a	Acquire more credentials to add to the current set

        This method works like :meth:`acquire`, except that it adds the
        acquired credentials for a single mechanism to a copy of the current
        set, instead of creating a new set for multiple mechanisms.
        Unlike :meth:`acquire`, you cannot pass None desired name or
        mechanism.

        If the `impersonator` argument is used, the credentials will
        impersonate the given name using the impersonator credentials
        (:requires-ext:`s4u`).

        If the `store` argument is used, the credentials will be acquired
        from the given credential store (:requires-ext:`cred_store`).
        Otherwise, the credentials are acquired from the default store.

        The credential store information is a dictionary containing
        mechanisms-specific keys and values pointing to a credential store
        or stores.

        Note that the `store` argument is not compatible with the
        `impersonator` argument.

        Args:
            name (Name): the name associated with the
                credentials
            mech (OID): the desired :class:`MechType` to be used with the
                credentials
            usage (str): the usage for the credentials -- either 'both',
                'initiate', or 'accept'
            init_lifetime (int): the desired initiate lifetime of the
                credentials, or None for indefinite
            accept_lifetime (int): the desired accept lifetime of the
                credentials, or None for indefinite
            impersonator (Credentials): the credentials to use to impersonate
                the given name, or None to not acquire normally
                (:requires-ext:`s4u`)
            store (dict): the credential store information pointing to the
                credential store from which to acquire the credentials,
                or None for the default store (:requires-ext:`cred_store`)

        Returns:
            Credentials: the credentials set containing the current credentials
                and the newly acquired ones.

        Raises:
            BadMechanismError
            BadNameTypeError
            BadNameError
            DuplicateCredentialsElementError
            ExpiredCredentialsError
            MissingCredentialsError
        NzMYou cannot use both the `impersonator` and `store` arguments at the same timezSYour GSSAPI implementation does not have support for manipulating credential storesz8Your GSSAPI implementation does not have support for S4U)�
ValueErrorrrrZ
add_cred_fromr"Zadd_cred_impersonate_namerZadd_credrr)	rrr rr'r(Zimpersonatorr	rrrr�add/s&9zCredentials.addcCstdkrtd��tj|�S)ayExport these credentials into a token

        This method exports the current credentials to a token that can
        then be imported by passing the `token` argument to the constructor.

        This is often used to pass credentials between processes.

        :requires-ext:`cred_imp_exp`

        Returns:
            bytes: the exported credentials in token form
        NzWYour GSSAPI implementation does not have support for importing and exporting creditials)r
rZexport_cred)rrrr�export�szCredentials.exportcCst|�d|j�ffS)N)r#r,)rrrr�
__reduce__�szCredentials.__reduce__)NNNNNrN)NNNrN)NrNFF)NNNr!)TTTT)TTTT)rNNNN)�__name__�
__module__�__qualname__�__doc__�	__slots__r�propertyrrrr�classmethodrr	r$rr)r+r,r-�
__classcell__rr)rrr
s. :
3
 

!
SrN)Z
gssapi.rawrrrrZ
gssapi._utilsrrZgssapirr
r"rrZCredsrrrrr�<module>s