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/lib/python3.9/site-packages/ipalib/__pycache__/rpc.cpython-39.opt-1.pyc
a

}�f���@sVdZddlmZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZddlZddlmZddlZddlmZdd	lmZdd
lmZmZmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'dd
l(m)Z*ddl+m,Z,ddl+m-Z-ddl.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?ddl@mAZAddlBmCZCddlDmEZEddl"mFZFddlGmHZHmIZIz4ddlJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTWnDeU�y,ddlVmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTYn0ejW�rDddlXmYZYnddlZm[ZYejW�r\e\Z]e�^e_�Z`dZadZbdd �Zcd!d"�Zdd#d$�Zed%d&�ZfdEd(d)�ZgdFd+d,�ZhdGd-d.�ZidHd/d0�ZjGd1d2�d2�ZkGd3d4�d4eQ�ZlGd5d6�d6el�ZmGd7d8�d8em�ZnGd9d:�d:en�ZoGd;d<�d<eo�ZpGd=d>�d>e�ZqGd?d@�d@eq�ZrGdAdB�dB�ZsGdCdD�dDeq�ZtdS)Ia`
RPC client and shared RPC client/server functionality.

This module adds some additional functionality on top of the ``xmlrpc.client``
module in the Python standard library (``xmlrpclib`` in Python 2).
For documentation on the ``xmlrpclib`` module, see:

    http://docs.python.org/2/library/xmlrpclib.html

Also see the `ipaserver.rpcserver` module.
�)�absolute_import)�DecimalN)�SSLError)�x509)�DNSException)�Connectible)�LDAP_GENERALIZED_TIME_FORMAT)�errors_by_code�UnknownError�NetworkError�XMLRPCMarshallError�	JSONError)�errors�capabilities)�context�
Connection)�Encoding)�ipautil)�session_storage)�Cookie)�DNSName�	query_srv)�_)�create_https_connection)�KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN�KRB5KRB_AP_ERR_TKT_EXPIRED�
KRB5_FCC_PERM�KRB5_FCC_NOFILE�KRB5_CC_FORMAT�KRB5_REALM_CANT_RESOLVE�KRB5_CC_NOTFOUND�
get_principal)�DN)�	Principal)�VERSION_WITHOUT_CAPABILITIES)�api)�json_encode_binary�json_decode_binary)
�Binary�Fault�DateTime�dumps�loads�ServerProxy�	Transport�
ProtocolError�MININT�MAXINT)�RemoteDisconnected)�
BadStatusLineZipa_sessionzX-IPA-Session-Cookiec
CsHzt�|t|�Wn0tyB}ztt|���WYd}~n
d}~00dS)z�
    Given a principal create or update the session data for that
    principal in the persistent secure storage.

    Raises ValueError if unable to perform the action for any reason.
    N)rZ
store_data�CCACHE_COOKIE_KEY�	Exception�
ValueError�str)�	principal�data�e�r;�./usr/lib/python3.9/site-packages/ipalib/rpc.py�%update_persistent_client_session_data�sr=c
CsDzt�|t�WSty>}ztt|���WYd}~n
d}~00dS)z�
    Given a principal return the stored session data for that
    principal from the persistent secure storage.

    Raises ValueError if unable to perform the action for any reason.
    N)r�get_datar4r5r6r7�r8r:r;r;r<�#read_persistent_client_session_data�sr@c
CsFzt�|t�Wn0ty@}ztt|���WYd}~n
d}~00dS)z�
    Given a principal remove the session data for that
    principal from the persistent secure storage.

    Raises ValueError if unable to perform the action for any reason.
    N)rZremove_datar4r5r6r7r?r;r;r<�%delete_persistent_client_session_data�srAcs^t|�ttfvr&t�fdd�|D��St|t�rJt�fdd�|��D��St|�tur^t|�St|�turrt	|�St|t
�r�|tks�|tkr�t	|�St|t
�r�t|�St|tj�r�t��d�r�t|�S|�t�St|t�r�t��d�r�dt	|�iSt	|�St|t��rt	|�St|tj��r4t�|�tj���d�St|tj��rZt�|�tj���d�S|S)a�
    Wrap all ``str`` in ``xmlrpc.client.Binary``.

    Because ``xmlrpc.client.dumps()`` will itself convert all ``unicode``
    instances into UTF-8 encoded ``str`` instances, we don't do it here.

    So in total, when encoding data for an XML-RPC packet, the following
    transformations occur:

        * All ``str`` instances are treated as binary data and are wrapped in
          an ``xmlrpc.client.Binary()`` instance.

        * Only ``unicode`` instances are treated as character data. They get
          converted to UTF-8 encoded ``str`` instances (although as mentioned,
          not by this function).

    Also see `xml_unwrap()`.

    :param value: The simple scalar or simple compound value to wrap.
    c3s|]}t|��VqdS�N��xml_wrap��.0�v��versionr;r<�	<genexpr>��zxml_wrap.<locals>.<genexpr>c3s |]\}}|t|��fVqdSrBrC�rF�krGrHr;r<rJ�sZdatetime_valuesZdns_name_values�__dns_name__�ascii) �type�list�tuple�
isinstance�dict�items�bytesr(r�unicode�intr0r1r"r7�datetimerZclient_has_capabilityr*�strftimerrr#�crypto_x509ZCertificate�base64�	b64encodeZpublic_bytes�
x509_EncodingZDER�decodeZCertificateSigningRequest)�valuerIr;rHr<rD�sJ
�



��
��rD�UTF-8cs�t|ttttf�r|S|dur"|St|t�r6|���St|ttf�rZt�fdd�|D��St|t	�r�d|vrxt
|d�St	�fdd�|��D��Sn,t|t�r�|j
St|t�r�tj�t|�d�St|��dS)aI
    Unwrap all ``xmlrpc.Binary``, decode all ``str`` into ``unicode``.

    When decoding data from an XML-RPC packet, the following transformations
    occur:

        * The binary payloads of all ``xmlrpc.client.Binary`` instances are
          returned as ``str`` instances.

        * All ``str`` instances are treated as UTF-8 encoded Unicode strings.
          They are decoded and the resulting ``unicode`` instance is returned.

    Also see `xml_wrap()`.

    :param value: The value to unwrap.
    :param encoding: The Unicode encoding to use (defaults to ``'UTF-8'``).
    Nc3s|]}t|��VqdSrB��
xml_unwraprE��encodingr;r<rJrKzxml_unwrap.<locals>.<genexpr>rNc3s |]\}}|t|��fVqdSrBrbrLrdr;r<rJ
sz%Y%m%dT%H:%M:%S)rSrWrX�float�boolrVr_rQrRrTrrUr(r9r*rY�strptimer7�	TypeError)r`rer;rdr<rc�s&


�


rcFcCs*t|�turt||�}nt||||dd�S)a�
    Encode an XML-RPC data packet, transparently wraping ``params``.

    This function will wrap ``params`` using `xml_wrap()` and will
    then encode the XML-RPC data packet using ``xmlrpc.client.dumps()``
    (from the Python standard library).

    For documentation on the ``xmlrpc.client.dumps()`` function, see:

        http://docs.python.org/library/xmlrpc.client.html#convenience-functions

    Also see `xml_loads()`.

    :param params: A ``tuple`` or an ``xmlrpc.client.Fault`` instance.
    :param methodname: The name of the method to call if this is a request.
    :param methodresponse: Set this to ``True`` if this is a response.
    :param encoding: The Unicode encoding to use (defaults to ``'UTF-8'``).
    T)�
methodname�methodresponsere�
allow_none)rPrRrDr+)�paramsrIrjrkrer;r;r<�	xml_dumpss�rncCs$t|jt�r t|j|j�|��S|SrB)rS�faultStringrVr)�	faultCoder_)r:rer;r;r<�decode_fault7srqc
CsLzt|�\}}t|�|fWStyF}zt|��WYd}~n
d}~00dS)a�
    Decode the XML-RPC packet in ``data``, transparently unwrapping its params.

    This function will decode the XML-RPC packet in ``data`` using
    ``xmlrpc.client.loads()`` (from the Python standard library).  If ``data``
    contains a fault, ``xmlrpc.client.loads()`` will itself raise an
    ``xmlrpc.client.Fault`` exception.

    Assuming an exception is not raised, this function will then unwrap the
    params in ``data`` using `xml_unwrap()`.  Finally, a
    ``(params, methodname)`` tuple is returned containing the unwrapped params
    and the name of the method being called.  If the packet contains no method
    name, ``methodname`` will be ``None``.

    For documentation on the ``xmlrpc.client.loads()`` function, see:

        http://docs.python.org/2/library/xmlrpclib.html#convenience-functions

    Also see `xml_dumps()`.

    :param data: The XML-RPC packet to decode.
    N)r,rcr)rq)r9rerm�methodr:r;r;r<�	xml_loads>s
rsc@s$eZdZdd�Zdd�Zdd�ZdS)�DummyParsercCs
g|_dSrB)r9��selfr;r;r<�__init__]szDummyParser.__init__cCs|j�|�dSrB)r9�append)rvr9r;r;r<�feed`szDummyParser.feedcCsd�|j�S)NrK)�joinr9rur;r;r<�closecszDummyParser.closeN)�__name__�
__module__�__qualname__rwryr{r;r;r;r<rt\srtc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�MultiProtocolTransportz,Transport that handles both XML-RPC and JSONcOst�|�|�dd�|_dS)N�protocol)r.rw�getr��rv�args�kwargsr;r;r<rwjs
zMultiProtocolTransport.__init__cCs&|jdkrt�}||fSt�|�SdS)N�json)r�rtr.�	getparser)rv�parserr;r;r<r�ns
z MultiProtocolTransport.getparsercCsF|jdkr|�dd�n|�dd�|�dtt|���|�|�dS)Nr�zContent-Typezapplication/jsonztext/xmlzContent-Length)r��	putheaderr7�lenZ
endheaders)rv�
connection�request_bodyr;r;r<�send_contentus

z#MultiProtocolTransport.send_contentN)r|r}r~�__doc__rwr�r�r;r;r;r<rgsrc@seZdZdZdd�ZdS)�LanguageAwareTransportz(Transport sending Accept-Language headercCs�t�||�\}}}z$t�tjd�jddd�d��}WntjyNd}Yn0t|t	�s^g}|�
d|�dd	�f�|�
d
dt|�f�|||fS)N��.�)�maxsplitr�en_uszAccept-Languager�-ZRefererzhttps://%s/ipa/xml)
r�
get_host_info�locale�	setlocale�LC_MESSAGES�split�lower�ErrorrSrQrx�replacer7)rv�hostZ
extra_headersr�langr;r;r<r��s,�
���

��z$LanguageAwareTransport.get_host_infoN)r|r}r~r�r�r;r;r;r<r��sr�c@seZdZdZdd�ZdS)�SSLTransportz2Handles an HTTPS transaction to an XML-RPC server.cCs�|�|�\}|_}|jr<||jdkr<t�d|�|jdSt|dttdd�tj	j
tj	jd�}|��t�d|�||f|_|jdS)NrzHTTP connection keep-alive (%s)r�i��ca_certfile)�tls_version_min�tls_version_maxzNew HTTP connection (%s))
r��_extra_headers�_connection�logger�debugr�getattrrr%�envr�r�Zconnect)rvr�Z_x509�connr;r;r<�make_connection�s

�
zSSLTransport.make_connectionN)r|r}r~r�r�r;r;r;r<r��sr�c@s�eZdZdZejjejjgZdd�Z	ddd�Z
dd�Zd	d
�Zddd
�Z
dd�Zdd�Zd dd�Zejrpdd�Ze�d�Zdd�Zdd�Zdd�ZdS)!�
KerbTransportzK
    Handles Kerberos Negotiation authentication to an XML-RPC server.
    cOs>tj|g|�Ri|��d|_|�dd�|_|�dd�|_dS)N�service�HTTP�ccache)r�rw�_sec_context�popr�r�r�r;r;r<rw�szKerbTransport.__init__NcCs�|j}|tkrtj|d��n||tkr.t���nj|tkr@t���nX|tkrRt�	��nF|t
krdt���n4|tkrvt�
��n"|tkr�t���ntjt|�d��dS)N�r���message)Zmin_coderrZServiceErrorrZ
NoCCacheErrorrZ
TicketExpiredrZBadCCachePermsrZBadCCacheFormatrZCannotResolveKDCr �CCacheError�
KerberosErrorrW)rvr:r��minorr;r;r<�_handle_exception�s 





zKerbTransport._handle_exceptioncCs
|jdS)Nr)r�rur;r;r<�	_get_host�szKerbTransport._get_hostcCs0|jD]$\}}||kr|j�||f�q,qdSrB)r��remove)rv�name�hrGr;r;r<�_remove_extra_header�sz"KerbTransport._remove_extra_headerTc	
Cs�t|jt�sg|_|�d�|rDttdd�}|rD|j�d|f�dS|��}|jd|�	d�d}zPd}|j
r�tjdd|j
id	�}t�
|tjj�}tj|||jd
�|_|j��}Wn6tjjy�}z|j||d�WYd}~n
d}~00|�|�dS)z�
        Two things can happen here. If we have a session we will add
        a cookie for that. If not we will set an Authorization header.
        r�session_cookieN�@�:rZinitiater�)�usage�store)�credsr��flagsr�)rSr�rQr�r�rrxr�r�r�r��gssapiZCredentials�NameZNameTypeZhostbased_serviceZSecurityContextr�r��step�
exceptions�GSSErrorr��_set_auth_header)	rv�
use_cookier�r�r�r�r��responser:r;r;r<�
get_auth_info�s0
��$zKerbTransport.get_auth_infocCs2|�d�|r.|j�ddt�|��d�f�dS)NZ
Authorizationznegotiate %srO)r�r�rxr\r]r_)rv�tokenr;r;r<r�s
��zKerbTransport._set_auth_headerc
Cs�|jr�|�dd�}d}|�d�D]V}|���d�\}}}|��dkr zt�|�d��}WqxWq t	t
fytYq 0q |s�tjdd��|jj
|d	�}|jjr�d|_d
S|�|�dS|jdkr�|jdd
�dSd
S)Nzwww-authenticater��,� Z	negotiaterOz,No valid Negotiate header in server responser�)r�TF�)r�)r�Z	getheaderr��strip�	partitionr�r\Z	b64decode�encoderi�UnicodeErrorrr�r�Zcompleter��statusr�)rvr��headerr�ZfieldrMZ_dummyrGr;r;r<�_auth_completes2
�

zKerbTransport._auth_completerc
Csjz�|�|�}|r|�d�|��tjrf|�|||�|�||�|�|�|�||�|j	dd�}n|�
|||||�|�	�}|jdkr�|��|jdkr�|�
|�s�q"t|||j|j|j��||_|�
|�s�q"|�|�WStjj�y}z|�|�WYd}~n^d}~0t�y8|��t�d|��Yn.t�yd|��tjd|dd��Yn0dS)	Nr�T)�	buffering��r�z&HTTP server has closed connection (%s)zHTTP connection destroyed (%s))�exc_info)r��set_debuglevelr��six�PY2Zsend_requestZ	send_hostZsend_user_agentr�Zgetresponse�_KerbTransport__send_requestr��readr�r/�reason�msg�verbose�parse_responser�r�r�r�r2r{r�r��
BaseException)rvr��handlerr�r�r�r�r:r;r;r<�single_request*sR



�
	

�
�zKerbTransport.single_requestcCs�|jdd�}|r|�d�|jrNtrN|jd|dd�|�dd�|�d�n|�d|�|�d|jf�|�||�|�	||�|S)	Nr�ZPOSTT)Zskip_accept_encoding�Accept-Encoding�gzip)r�r�z
User-Agent)
r�r�Zaccept_gzip_encodingr�Z
putrequestr�rxZ
user_agentZsend_headersr�)rvr�r�r�r�r�Zheadersr;r;r<Z__send_requestks

�zKerbTransport.__send_requestz.*?(&expiry=\d+).*?cCs*|��}|j�|�D]}|�|d�}q|S)Nr�)�http_cookie�	expiry_re�findallr�)rvr�r�Zexpr;r;r<�_slice_session_cookie�sz#KerbTransport._slice_session_cookiec
Cs|durdSttdd�}ttdd�}t�dt|�|�t|t�sF|g}d}z:|D]0}tj|t	|t
j
jt
jj
d�d�}|durPq�qPWn4ty�}zt�d||�WYd}~dSd}~00|dur�dS|�|�}t�d||�zt||�Wnt�yYn0dS)	a�
        Given the contents of a Set-Cookie header scan the header and
        extract each cookie contained within until the session cookie
        is located. Examine the session cookie if the domain and path
        are specified, if not update the cookie with those values from
        the request URL. Then write the session cookie into the key
        store for the principal. If the cookie header is None or the
        session cookie is not present in the header no action is
        taken.

        Context Dependencies:

        The per thread context is expected to contain:
            principal
                The current pricipal the HTTP request was issued for.
            request_url
                The URL of the HTTP request.

        Nr8�request_urlzreceived Set-Cookie (%s)'%s'�Ztz�Z	timestampz&unable to parse cookie header '%s': %sz$storing cookie '%s' for principal %s)r�rr�r�rPrSrQr�get_named_cookie_from_string�COOKIE_NAMErY�now�timezone�utcr5�errorr�r=)rvZ
cookie_headerr8r�r�Zcookier:�
cookie_stringr;r;r<�store_session_cookie�sH�
���
�
�z"KerbTransport.store_session_cookiecCs6tjr|j�d�}n|j�d�}|�|�t�||�S)Nz
Set-Cookie)r�r�r�Z
getheadersZget_allr�r�r�)rvr�r�r;r;r<r��s

zKerbTransport.parse_response)N)T)r)r|r}r~r�r��RequirementFlag�mutual_authentication�out_of_sequence_detectionr�rwr�r�r�r�r�r�r�r��PY3r��re�compiler�r�r�r�r;r;r;r<r��s$�

"
@
=r�c@s&eZdZdZejjejjejjgZ	dS)�DelegatedKerbTransportzb
    Handles Kerberos Negotiation authentication and TGT delegation to an
    XML-RPC server.
    N)
r|r}r~r�r�r�Zdelegate_to_peerr�r�r�r;r;r;r<r��s
�r�c@sZeZdZdZdZeZdZdZdd�Z	dd�Z
dd�Zdd	d
�Zdd�Z
d
d�Zdd�ZdS)�	RPCClientzq
    Forwarding backend plugin for XML-RPC client.

    Also see the `ipaserver.rpcserver.xmlserver` plugin.
    Nc
Cs�tj�|�\}}}}}}g}d|jj}	zt|	�}
WntyJg}
Yn0|
D],}t|j��	d�}|�
dt�|�|f�qP||vr�|�
|�|�d|�|S)zP
        Create a list of urls consisting of the available IPA servers.
        z_ldap._tcp.%s.r�zhttps://%s%sr)�urllib�parse�urlparser��domainrrr7�target�rstriprxrZ
format_netlocr��insert)
rv�rpc_uriZ_schemeZ_netloc�pathZ_paramsZ_queryZ	_fragmentZserversr�ZanswersZanswer�serverr;r;r<�get_url_list�s$
�


�

zRPCClient.get_url_listc
Cs�z$t|�}|durWdS|�d�}Wn2tyV}zt�d|�WYd}~dSd}~00z"tj|ttjj	tj
jd�d�}Wn2ty�}zt�d|�WYd}~dSd}~00|S)a
        Retrieves the session cookie for the given principal from the
        persistent secure storage. Returns None if not found or unable
        to retrieve the session cookie for any reason, otherwise
        returns a Cookie object containing the session cookie.
        N�utf-8z%Error reading client session data: %sr�r�z7Error retrieving cookie from the persistent storage: %s)r@r_r5r�r�rr�r�rYr�r�r�)rvr8r�r:r�r;r;r<�*get_session_cookie_from_persistent_storages(
�
�z4RPCClient.get_session_cookie_from_persistent_storagec
Csj|}ttdd�}|�|�}|dur2t�d|�|St�d||�z|�|�Wn�tjy�}z>t�d||�zt|�Wnt	y�Yn0|WYd}~Sd}~0tj
y�}zt�d|�|WYd}~Sd}~0t	�y}zt�d|�|WYd}~Sd}~00t�d|���t
td	|���tj�|�\}}}}	}
}|j}tj�||||	|
|f�}|S)
aE
        Attempt to load a session cookie for the current principal
        from the persistent secure storage. If the cookie is
        successfully loaded adjust the input url's to point to the
        session path and insert the session cookie into the per thread
        context for later insertion into the HTTP request. If the
        cookie is not successfully loaded then the original url is
        returned and the per thread context is not modified.

        Context Dependencies:

        The per thread context is expected to contain:
            principal
                The current pricipal the HTTP request was issued for.

        The per thread context will be updated with:
            session_cookie
                A cookie string to be inserted into the Cookie header
                of the HTPP request.

        r8NzFfailed to find session_cookie in persistent storage for principal '%s'zKfound session_cookie in persistent storage for principal '%s', cookie: '%s'z,deleting session data for principal '%s': %sz,not sending session cookie, URL mismatch: %sz-not sending session cookie, unknown error: %sz(setting session_cookie into context '%s'r�)r�rrr�r�Zhttp_return_okrZExpiredrAr5ZURLMismatchr�r��setattrrrr�session_path�
urlunparse)
rv�urlZoriginal_urlr8r�r:�scheme�netlocrrm�query�fragmentZsession_urlr;r;r<�apply_session_cookie$sT�������zRPCClient.apply_session_cookiec
Cs$|dur|jjj}|dur$|jjj}|dur6|jjj}|durH|jjj}|t_|j|j}z^t	|d�}t
tdd�}||kr�zttd�Wnty�Yn0t
td|�|s�|�|�}Wntjtfy�Yn0|�|�}	dd|d�}
|	D�]}tdd�D�]}|�d	��r |�rt}
nt}
nt}
|
|jd
|d�|
d<t�d
|�t
td|�|j|fi|
��}t|	�dk�r||Sz�t
|d�}z|gi�Wndt�y�}zJt|�}|jt v�r�t |j}||j!d��nt"|j|j!|d��WYd}~n
d}~00|WStj#�y �Yq�t$�y�}z�t%td��r�|j&dk�r�ttd�zt'|�Wnt(�yrYn0WYd}~q�|�s��nt�)d||�WYd}~q�WYd}~q�d}~0t(�y}z2|�sԂnt�)d||�WYd}~q�WYd}~q�d}~00q�q�t*t+d�d�,|	�d��dS)N)Zccache_namer8r�Tra)rlrer�r�zhttps://r�)r�r�r��	transportz	trying %sr�r�Zpingr���coder�r	r�zConnection to %s failed with %szany of the configured serversz, ��urir�)-r%r�r��fallback�delegateZtls_ca_certrr��env_rpc_uri_keyr!r��delattr�AttributeErrorr
rrr�r6r
�range�
startswithr�r�r�r�r�r��server_proxy_classr�r)rqrpr	ror
r�r/�hasattr�errcoderAr5�inforrrz)rvr�r�rrr�rr8Zstored_principalZurlsZproxy_kwrZ_try_numZtransport_class�serverproxy�commandr:r�r;r;r<�create_connectionls�





�
�


�
�"�(�zRPCClient.create_connectioncCs*tt|jd�}|dur&|jj}|��dSrB)r�r�idr��_ServerProxy__transportr{)rvr�r;r;r<�destroy_connection�szRPCClient.destroy_connectioncCs||�S)z"Call the command with given paramsr;)rvr(rmr;r;r<�
_call_command�szRPCClient._call_commandcOsDttdd�}t|j|�}||g}d}td|�D�]�}t�d|d||j|�z|�||�WSty�}	zZt	|	�}	t�d|	j
||	j�|	j
tvr�t|	j
}
|
|	jd��t
|	j
|	j|d	��WYd}	~	q.d}	~	0t�y�}	z�ttd
d�}|�r�|	jdk�r�ttd
�zttdd�}t|�Wn2t�yR}
zt�d
|
�WYd}
~
n
d}
~
00|�tj�d�|jj|jj|jj�}tt|jt||j��WYd}	~	q.t||	j d��WYd}	~	q.d}	~	0t!t"j#f�y�}	zt|t$|	�d��WYd}	~	q.d}	~	0t%t&f�y,}	zt't$|	�d��WYd}	~	q.d}	~	00q.t|t(d�d��dS)a�
        Forward call to command named ``name`` over XML-RPC.

        This method will encode and forward an XML-RPC request, and will then
        decode and return the corresponding XML-RPC response.

        :param command: The name of the command being forwarded.
        :param args: Positional arguments to pass to remote command.
        :param kw: Keyword arguments to pass to remote command.
        r�Nrrz+[try %d]: Forwarding '%s' to %s server '%s'r�z"Caught fault %d from server %s: %sr�rr�r�r8z1Error trying to remove persisent session data: %sZ
KRB5CCNAMEr�r�z.Exceeded number of tries to forward a request.))r�rr�r!r�r�r�r-r)rqrpror	r
r/r%rrAr5r)�os�environr�r�r�rrr
r*rZ
disconnectr�errmsgr�socketr�r7�
OverflowErrorrirr)rvr�r��kwr	r(rmZ	max_triesZtry_numr:r�r�r8�e2r'r;r;r<�forward�sf�
�

�
��
�"$&�zRPCClient.forward)NNNNN)r|r}r~r�rr-r#r�rr
rrr)r,r-r6r;r;r;r<r��s H�
nr�c@s$eZdZdZeZdZdZdd�ZdS)�	xmlclientz/ipa/session/xmlZxmlZ
xmlrpc_uricCs*|d�dt�}t||�}||�}t|�S)Nr�rI)r�r$rDrc)rvr(rmrI�resultr;r;r<r-3s
zxmlclient._call_commandN)	r|r}r~rr-r#r�rr-r;r;r;r<r7-s
r7c@s$eZdZdd�Zdd�Zdd�ZdS)�JSONServerProxycCsDtj�|�}|jdvrtd��|j|_|j|_||_	||_
||_dS)N)�http�httpszunsupported XML-RPC protocol)rr�urlsplitr�IOErrorr�_JSONServerProxy__hostr�_JSONServerProxy__handler�_JSONServerProxy__transport�_JSONServerProxy__verboser+)rvrrrer�rlZ	split_urir;r;r<rw;s
zJSONServerProxy.__init__c
CsN|jdk}t|�|dd�}|d�dt�}t|||d�}|rHt�d|�|jj|j	|j
|�d�|jd	kd
�}|r�t�dtj
t�|�dd
d��zt|�}Wn2ty�}ztt|�d��WYd}~n
d}~00|�d�}|�rFzt|d}	Wn0t�yt|�d�|�d�|j	d��Yn(0|�di�}
|d|
d<|	fi|
���|dS)N�r)rrrmr*r�rI)Zpretty_printzRequest: %sr�)r�zResponse: %sT�)Z	sort_keys�indentr.r�rr�rr9r8)rArWr�r$r&r�r&r@Zrequestr>r?r�r�r+r,r'r6r
r7r	�KeyErrorr
)rvr�r�Z
print_jsonZpayloadrIr�r:r�Zerror_classr4r;r;r<Z	__requestLsP
����$
�zJSONServerProxy.__requestcs��fdd�}|S)Ncs���|�SrB)�_JSONServerProxy__request)r��r�rvr;r<�_call}sz*JSONServerProxy.__getattr__.<locals>._callr;)rvr�rIr;rHr<�__getattr__|szJSONServerProxy.__getattr__N)r|r}r~rwrGrJr;r;r;r<r9:s0r9c@seZdZdZeZdZdZdS)�
jsonclientz/ipa/session/jsonr�Zjsonrpc_uriN)r|r}r~rr9r#r�rr;r;r;r<rK�srK)ra)NFra)ra)ra)ur�Z
__future__rZdecimalrrYZloggingr/r�r\r�r�r2r�rZsslrZcryptographyrr[r�Z
dns.exceptionrr�Zipalib.backendrZipalib.constantsrZ
ipalib.errorsr	r
rrr
ZipalibrrZipalib.requestrrZipalib.x509rr^Z	ipapythonrrZipapython.cookierZipapython.dnsutilrrZipalib.textrZipalib.utilrZipalib.krb_utilsrrrrrrr r!Zipapython.dnr"Zipapython.kerberosr#Zipalib.capabilitiesr$r%Zipalib.ipajsonr&r'Z	xmlrpclibr(r)r*r+r,r-r.r/r0r1�ImportErrorZ
xmlrpc.clientr�Zhttp.clientr2Zhttplibr3r7rWZ	getLoggerr|r�r�r4r=r@rArDrcrnrqrsrtrr�r�r�r�r�r7r9rKr;r;r;r<�<module>s�(
46
A
+�
!


T
H