
    0j7                         	 d dl mZ n# e$ r	 d dlmZ Y nw xY w	 d dlmZ n# e$ r	 d dlmZ Y nw xY wd dlZ ej        e	          Z
d Zd Z G d de          ZdS )	    )urlparse)cElementTree)ElementTreeNc                 Z    d                     | dgt          |           dz
  z  z             S )N/z..   )joinlen)route_to_leafs    P/home/rurouni/.hermes/hermes-agent/venv/lib/python3.11/site-packages/msal/mex.py_xpath_of_rootr   )   s-    88MTFc-.@.@.B$CCDDD    c                     |j         | fi |}|                                 	 t          |j                                                  S # t
          j        $ r( t                              d|j	        |j                    w xY w)NzMalformed MEX document: %s, %s)
getraise_for_statusMextext&get_wstrust_username_password_endpointET
ParseErrorlogger	exceptionstatus_code)mex_endpointhttp_clientkwargsmex_resps       r   send_requestr   .   s    {|66v66H8=!!HHJJJ=   ,h.BHM	S 	S 	Ss   %A
 
7Bc                   b    e Zd Zdddddddddd	d
d
dddZdZdZd Zd Zd Zd Z	d Z
d Zd ZdS )r   z http://schemas.xmlsoap.org/wsdl/z9http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702z4http://schemas.xmlsoap.org/ws/2005/07/securitypolicyzRhttp://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsdz$http://www.w3.org/2005/08/addressingz3http://schemas.microsoft.com/ws/06/2004/policy/httpz'http://schemas.xmlsoap.org/wsdl/soap12/z,http://schemas.xmlsoap.org/ws/2004/09/policyz'http://www.w3.org/2003/05/soap-envelopez0http://docs.oasis-open.org/ws-sx/ws-trust/200512z%urn:oasis:names:tc:SAML:1.0:assertionz+http://schemas.xmlsoap.org/ws/2005/02/trust)wsdlspsp2005wsuwsawsa10httpsoap12wspswsttrustsamlwst2005z:http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issuez5http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issuec                 8    t          j        |          | _        d S )N)r   
fromstringdom)selfmex_documents     r   __init__zMex.__init__N   s    =..r   c                      d j         d         z  t           fd j                            t	          |           j                   D                       S )Nz{%s}Idr#   c                     g | ]E}|                     j                  d                    |                                        FS )Nz#{})findNSformatr   ).0policybinding_xpathid_attrr1   s     r   
<listcomp>z'Mex._get_policy_ids.<locals>.<listcomp>S   sV     @ @ @{{=$'22> LLG!4!455 ?>>r   )r7   setr0   findallr   )r1   components_to_leafr;   r<   s   ` `@r   _get_policy_idszMex._get_policy_idsQ   s    TWU^+ @ @ @ @ @ @(**>:L+M+MtwWW@ @ @ A A 	Ar   c                     g d}|                      |d          }g d}|                    |                      |d                     |S )N)
wsp:Policywsp:ExactlyOnewsp:Allz"sp:SignedEncryptedSupportingTokensrC   zsp:UsernameTokenrC   zsp:WssUsernameToken10z.//sp:TransportBinding)rC   rD   rE   zsp2005:SignedSupportingTokensrC   zsp2005:UsernameTokenrC   zsp2005:WssUsernameToken10.//sp2005:TransportBinding)rA   update)r1   pathpoliciespath2005s       r   !_get_username_password_policy_idsz%Mex._get_username_password_policy_idsX   sl    G G G ''.FGGO O O 	,,X7STTUUUr   c                 2    |                      g dd          S )N)rC   rD   rE   zhttp:NegotiateAuthenticationrF   )rA   )r1   s    r   _get_iwa_policy_idszMex._get_iwa_policy_idsc   s&    ##WWW(* * 	*r   c                    i }| j                             d| j                  D ]}|                    d| j                                      d          dk    r5|                    d| j                                      d          }|                    d| j                  D ]0}|                    d          |d	||                    d
          <   1|S )Nzwsdl:bindingzsoap12:binding	transportz$http://schemas.xmlsoap.org/soap/httpzwsdl:operation/soap12:operation
soapActionzwsp:PolicyReferenceURI)
policy_uriactionname)r0   r?   r7   r6   r   )r1   bindingsbindingrS   prs        r   _get_bindingszMex._get_bindingsh   s    x''@@ 	C 	CG-tw77;;KHH:; ;\\147< <<?C<M<M oo&;TWEE C C"$&&--61C 1CV,,--C r   c                    g }| j                             d| j                  D ]}|                    d                              d          d         }|                    |          }|rv|d         |v rl|                    d| j                  }|O|j                                                            d          r#|	                    |j        |d         d	           |S )
Nzwsdl:service/wsdl:portrV   :rR   z%wsa10:EndpointReference/wsa10:Addresszhttps://rS   )addressrS   )
r0   r?   r7   r   splitr6   r   lower
startswithappend)r1   rU   
policy_ids	endpointsportbinding_namerV   r\   s           r   _get_endpointszMex._get_endpointsu   s    	H$$%=twGG 	P 	PD88I..44S99"=Lll<00G P7<0J>>))$KTWUU&7<+=+=+?+?+J+J:+V+V&$$$+LGH<MNNP P Pr   c                     |                      |                                 |                                           }|D ]}|d         | j        k    r|c S |r|d         ndS )zDReturns {"address": "https://...", "action": "the soapAction value"}rS   r   N)re   rX   rK   	ACTION_13)r1   rb   es      r   r   z*Mex.get_wstrust_username_password_endpoint   sw    ''""$$d&L&L&N&NP P	 	 	A{dn,, -(2y||d2r   N)__name__
__module____qualname__r7   rg   ACTION_2005r3   rA   rK   rM   rX   re   r    r   r   r   r   9   s         3IHc57E;=6AC7@

 

B  MIIK/ / /A A A	 	 	* * *
  
 
 
3 3 3 3 3r   r   )urllib.parser   ImportError	xml.etreer   r   r   logging	getLoggerri   r   r   r   objectr   rm   r   r   <module>rt      s  8"%%%%%%% " " "!!!!!!!!",,,,,,,, , , ,++++++++,  
	8	$	$E E E
  O3 O3 O3 O3 O3& O3 O3 O3 O3 O3s   	 " 00