
    i#                     P   S SK r S SKJrJr  S SKJrJrJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S\ R,                  \ R.                  \\\ R2                  \   4      S\ R,                  \   S\S\S\ R,                  \   S\S\S\S\S\ R4                  S\4S jrSSSSS\R8                  S\R:                  4S\ R,                  \ R.                  \\\ R2                  \   4      S\ R,                  \   S\S\S\ R,                  \   S\S\S\S\ R4                  S\4S jjrSSS\R8                  S\R:                  4SS.S\S\S\ R,                  \   S\S\S\S\ R,                  \ R.                  \\\ R2                  \   4      S\ R4                  S\4S jjjrg)    N)ContextProxy
ContextReq)
CredentialNTLMHashunify_credentials)CredSSPProxy)GSSAPIProxy)NegotiateProxy)	NTLMProxy)	SSPIProxy)GssChannelBindings)NegotiateOptionsusernamepasswordhostnameservicechannel_bindingscontext_reqprotocoloptionsusagekwargsreturnc	                    UR                  5       n
[        X5      n[        R                  " US9n[        R                  " US9n[
        R                  [
        R                  -  [
        R                  -  [
        R                  -  nX~-  S:g  n[        5       nU H<  n[        U[        5      (       d  M  UR                  S5        UR                  S5        M>     U(       a!  U H  nXl;   d  M
  UR                  U5        M     U
S:X  a  [        nOU[
        R                  -  (       d  U(       d  X;   a  [        nOU[
        R                  -  (       d  U(       d  U
S:X  d  X;   a  [        nOpU[
        R                  -  (       d  U(       d  U
S:X  a  [         nODU[
        R                  -  (       d  U(       d  U
S:X  a  U
S:X  a  SOU
n
["        nO[%        SU-  5      eU" S	US UUUUUU
US.	U	D6$ )
N)r   r   	negotiatentlmcredsspkerberoszEInvalid protocol specified '%s', must be kerberos, negotiate, or ntlm)	r   r   r   r   r   r   r   r   r    )lowerr   r   available_protocolsr	   r   use_sspi
use_gssapiuse_negotiateuse_ntlmset
isinstancer   addremover   r
   r   
ValueError)r   r   r   r   r   r   r   r   r   r   protocredentialssspi_protocolsgssapi_protocols	use_flagsuse_specifiedsspi_removecredproxys                      E/home/james-whalen/.local/lib/python3.13/site-packages/spnego/auth.py_new_contextr5      s    NNE#H7K227CN"66wG
 	!!

%
%	&

(
(	) 
#
#	$  '1,M %KdH%%OOK(OOF#	  #H)%%h/ $ 		#,,	,]uG^	#..	.u
2e6O	#11	1-EU`L`	#,,	,]uPV;.E `ckkll )      unspecifiedhostr   c                 "    [        XX#XEXgS4	0 UD6$ )a  Create a client context to be used for authentication.

Credentials can be provides in 3 different ways:

    * omitted entirely
    * `username` set to a string with an optional password
    * `username` set to a single or list of :class:`Credential` objects

If the credential is omitted the authentication protocol will use a
protocol specific mechanism to find the credential in some cache. If no
cache or credentials are found an exception is raised.

If `username` is a string but `password` is not defined then the provider
specific cache is used but for the principal specified. If `password` is
specified then a new credential is retrieved using the username/password
combiniation. Using both `username` and `password` is the same as using
:class:`Password` as a credential.

If `username` is a, or list of, `Credential` object the object(s) are
passed into the authentication implementation for use. The behaviour of
these credentials are defined by the authentication protocol
implementation that uses the credential(s). Currently the :class:`Passowrd`
credential is supported by all authentication protocols and is the same
as specifying the username/password as separate arugments.

The ``negotiate`` protocol can be given a list of credentials for each of
the sub auth protocols it negotiates to use. For example to have Negotiate
use a Kerberos CCache for Kerberos and an NT/LM hash value for NTLM the
following can be specified::

    import spnego

    credential = [
        spnego.KerberosCCache(ccache="FILE:/tmp/my-ccache"),
        spnego.NTLMHash(
            username="user",
            nt_hash="8ADB9B997580D69E69CAA2BBB68F4697",
        )
    ]
    client = spnego.auth(credential, hostname="server")

In the example above, the negotiate protocol will attempt use the CCache
for Kerberos auth and fallback to the NT/LM hash for NTLM auth if
Kerberos fails. If a credential for a specific sub protocol is not
available then Negotiate will move onto the next available one.

Args:
    username: The username/credential(s) to authenticate with. Certain providers can use a cache if omitted.
    password: The password to authenticate with. Should only be specified when username is a string.
    hostname: The principal part of the SPN. This is required for Kerberos auth to build the SPN.
    service: The service part of the SPN. This is required for Kerberos auth to build the SPN.
    channel_bindings: The optional :class:`spnego.channel_bindings.GssChannelBindings` for the context.
    context_req: The :class:`spnego.ContextReq` flags to use when setting up the context.
    protocol: The protocol to authenticate with, can be `ntlm`, `kerberos`, `negotiate`, or `credssp`.
    options: The :class:`spnego.NegotiateOptions` that define pyspnego specific options to control the negotiation.
    kwargs: Optional arguments to pass through to the authentiction context.

Returns:
    ContextProxy: The context proxy for a client.
initiater5   )	r   r   r   r   r   r   r   r   r   s	            r4   clientr<   b   s'    N H/?hakou r6   )r,   r,   c                $    [        USXX#XES4	0 UD6$ )aD  Create a server context to be used for authentication.

It is only possible to specify a credential when running on Windows and
using Kerberos either through Negotiate or Kerberos directly. Other
platforms and protocols may be supported in the future.

Args:
    hostname: The principal part of the SPN. This is required for Kerberos auth to build the SPN.
    service: The service part of the SPN. This is required for Kerberos auth to build the SPN.
    channel_bindings: The optional :class:`spnego.channel_bindings.GssChannelBindings` for the context.
    context_req: The :class:`spnego.ContextReq` flags to use when setting up the context.
    protocol: The protocol to authenticate with, can be `ntlm`, `kerberos`, `negotiate`, or `credssp`.
    options: The :class:`spnego.NegotiateOptions` that define pyspnego specific options to control the negotiation.
    credentials: A credential or list or credentials to use with the server auth context.
    kwargs: Optional arguments to pass through to the authentiction context.

Returns:
    ContextProxy: The context proxy for a client.
Nacceptr;   )r   r   r   r   r   r   r,   r   s           r4   serverr?      s(    < T8.>X`hlr r6   ) typingspnego._contextr   r   spnego._credentialr   r   r   spnego._credsspr   spnego._gssr	   spnego._negotiater
   spnego._ntlmr   spnego._sspir   spnego.channel_bindingsr   spnego.exceptionsr   OptionalUnionstrListAnyr5   defaultnoner<   r?   r   r6   r4   <module>rQ      sf    4 F F ( # , " " 6 .Noofll3
FKK
<S+STUNooc"N N 	N
 oo&89N N N N N jjN Nd Y]%)!<@(00 0 5 5Ioofll3
FKK
<S+STUIooc"I I 	I
 oo&89I I I I jjI IZ "<@(00 0 5 5  \`    oo&89  	 
     c:v{{:?V.V!WX  jj   r6   