File: //lib64/python3.9/site-packages/gssapi/__pycache__/creds.cpython-39.pyc
a
��_�@ � @ sj d dl mZ d dl mZ d dlmZmZ d dlm Z ed�Z
ed�Zed�Zed�Z
G d d
� d
ej�ZdS )� )�creds)�named_tuples)�import_gssapi_extension�_encode_dict)�namesZcred_imp_expZs4uZ
cred_storeZrfc5588c s� e Zd ZdZdZd"� fdd� Zedd� �Zed d
� �Zedd� �Z ed
d� �Z
ed#dd��Zd$dd�Z
d%dd�Zd&dd�Zd'dd�Zd(dd�Zdd� Zd d!� 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^ |d ur|}n>|d ur2t d u r&td��t �|�}n| j|||||d�} | j}tt| ��| |�S )N�WYour 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__r �2/usr/lib64/python3.9/site-packages/gssapi/creds.pyr 1 s �zCredentials.__new__c C s | j ddddd�jS )z.Get the name associated with these credentialsTF�r r r r )�inquirer ��selfr r r r E s �zCredentials.namec C s | j ddddd�jS )z/Get the remaining lifetime of these credentialsFTr )r r r r r r r K s �zCredentials.lifetimec C s | j ddddd�jS )z(Get the mechanisms for these credentialsFTr )r r r r r r r Q s �zCredentials.mechsc C s | j ddddd�jS )z>Get the usage (initiate, accept, or both) of these credentialsFTr )r r r r r r r W s �zCredentials.usagec C s^ |du rt �||||�}n*tdu r*td��t|�}t�|||||�}t�| |jd�|j |j
�S )a Acquire 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
N�SYour GSSAPI implementation does not have support for manipulating credential stores�r )�rcredsZacquire_cred�rcred_cred_storer
r Zacquire_cred_from�tuplesZAcquireCredResultr r r )r r r r r r r r r r r ] s *���zCredentials.acquireFc C sZ |du r*t du rtd��t �| ||||�S tdu r:td��t|�}t�|| ||||�S dS )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_rfc5588r
Z
store_credr# r Zstore_cred_into)r r r �mechZ overwriteZset_defaultr r r r � s "
��zCredentials.store�initiatec C s2 t du rtd��t �| ||||�}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
N�8Your GSSAPI implementation does not have support for S4Ur! )� rcred_s4ur
Zacquire_cred_impersonate_name�typer )r r r r r r r r r �impersonate� s �zCredentials.impersonateTc C sD t �| ||||�}|jdur*t�|j�}nd}t�||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)
r"