File: //lib64/python3.6/site-packages/gssapi/__pycache__/sec_contexts.cpython-36.pyc
3
�O[�J � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlm Z m
Z
d dljZ
d dlmZ d dlmZ d dlmZ e jej�G d d
� d
ej��ZdS )� N)�sec_contexts)�message)�named_tuples)�RequirementFlag�IntEnumFlagSet)�_utils)�Name)�Credentialsc s e Zd ZdZd6� fdd� Zd7dd�Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zd8dd�Zdd� Z
dd� Zd9Zejd!d"� �Zed#d$� �Zed%d&� �Zejdd'�Zejdd(�Zejdd)�Zejdd*�Zejdd+�Zeejd,d-� ��Zejd:d.d/��Zd0d1� Zd;d2d3�Z d4d5� Z!� Z"S )<�SecurityContexta� A GSSAPI Security Context
This class represents a GSSAPI security context that may be used
with and/or returned by other GSSAPI methods.
It inherits from the low-level GSSAPI
:class:`~gssapi.raw.sec_contexts.SecurityContext` class,
and thus may used with both low-level and high-level API methods.
This class may be pickled and unpickled (the attached delegated
credentials object will not be preserved, however).
Nc
s$ |d k rt j|�}tt| �j| |�S )N)�
rsec_contextsZimport_sec_context�superr
�__new__)
�cls�base�token�name�creds�lifetime�flags�mech�channel_bindings�usage)� __class__� �$/usr/lib64/python3.6/sec_contexts.pyr
s
zSecurityContext.__new__c
C s6 d| _ |dkr�|dkr�| dk r@| dkr8d}
tj|
dd��| | _n2|dk r\|jdkr\|j| _n|dk rld| _nd| _| jdkr�|dkr�td��|| _|| _tt|�| _ || _
n(|dk s�|dk s�|dk s�|dk r�td ��|| _|| _d| _
nDy| jr�d| _nd| _W n* tjk
�r* d
}
tj|
dd��Y nX d| _dS )a
The constructor creates a new security context, but does not begin
the initiate or accept process.
If the `base` argument is used, an existing
:class:`~gssapi.raw.sec_contexts.SecurityContext` object from
the low-level API is converted into a high-level object.
If the `token` argument is passed, the security context is imported
using the token.
Otherwise, a new security context is created.
If the `usage` argument is not passed, the constructor will attempt
to detect what the appropriate usage is based on either the existing
security context (if `base` or `token` are used) or the argument set.
For a security context of the `initiate` usage, the `name` argument
must be used, and the `creds`, `mech`, `flags`,
`lifetime`, and `channel_bindings` arguments may be
used as well.
For a security context of the `accept` usage, the `creds` and
`channel_bindings` arguments may optionally be used.
N�initiate�acceptz+Usage must be either 'initiate' or 'accept'zsecurity context)�objZbothzNYou must pass the 'name' argument when creating an initiating security contextzVYou must pass at most the 'creds' argument when creating an accepting security contextz7Cannot extract usage from a partially completed context)r r )Z _last_err�excsZUnknownUsageErrorr � TypeError�_target_name�_mechr r �_desired_flags�_desired_lifetime�_channel_bindings�_creds�_delegated_creds�locally_initiated�MissingContextError� _complete)�selfr r r r r r r r r �msgr r r �__init__&