
    i#                     X   d dl Z d dlZd dlZd dlZd dlZd dlmZmZ ej        j	        Z
ej        j        Zej        j        Zej        j        Z	  ej        d          Zd Zd ZddZded	efd
Zd Zd Zd Zdededej        fdZ  ej!        de            ej"        de            dS )    N)urlparseparse_qszs(?P<objservername>[^/]+)/n/(?P<namespace>[^/]+)/b/(?P<bucketname>[^/]+)/o/(?P<filename>[^/]+)(/c/(?P<alias>[^/]+))?c                    i }t          |           \  }}|                     d          }||                                }||dk    rt          |          }n|dk    s|dk    rt          ||          }t	          | d          t	          | d          t	          | d          d	} |j        di |}t          |j                  }	t          j	        |	          }
|                     d
          }|r|
|         }
t	          |
d          |d<   |j
        f|
                    d          |d<   d|
v rJ|
d         x|d<   }|d         dk    r1|                    di           }|                    d|           ||d<   |
                    d          |d<   |
                    d          |d<   |
                    dd           |d<   |                    |           d S )NauthenticationOCI_DEFAULTOCI_INSTANCE_PRINCIPALOCI_RESOURCE_PRINCIPALconfigsignerfilename
bucketname	namespace)object_namebucket_namenamespace_namealiasconnect_descriptoruserpasswordtypeocivaultmethod
credentialconfig_time_to_live config_time_to_live_grace_periodpyo )_get_credentialgetupperoci_object_storage_client_get_required_parameter
get_object_stream_to_stringdatajsonloadsr   
setdefaultset_from_config)
parametersconnect_paramsr   r   r   auth_method
client_ociget_object_requestget_object_responserespsettings
user_aliaspwdr   s                 t/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/oracledb/plugins/oci_config_provider.py_get_configr6   6   s1   F(44J..!122K!''))k]::.z::

///222.f
 
 

 /z:FF.z<HH1*kJJ  0*/EE2DEE0566Dz$H((J (J' $;&$ $F 
 "!f--v!!'/
';;F:6{j((!$0@"!E!E))(K@@@/9|, %-LL1F$G$GF !19*2 2F-.
 LL--F5M ""6*****    c           	      @   |                      d|                      d                    }||                                }|                      dt          |                      d                              }	 ||dk    rt                      dfS n# t          j        j        $ r d| v ryd| v rut          | d	         d
          5 }|                                }ddd           n# 1 swxY w Y   t          | d         | d         | d         | d	         ||          }|dfcY S Y nw xY w|dk    r5t          j
        j                                        }t          |          |fS |dk    r't          j
        j                                        }i |fS d}t          |          )zi
    Returns the appropriate credential given the input supplied by the original
    connect string.
    r   r   N
oci_regionobjservernamer   oci_tenancyoci_useroci_key_fileroci_fingerprint)tenancyr   fingerprintkey_fileprivate_key_contentregionr   )rD   r	   z>Authentication options were not available in Connection String)r    r!   _retrieve_regionoci_from_fileoci
exceptionsClientErroropenreaddictauthsigners%InstancePrincipalsSecurityTokenSignerget_resource_principals_signer	Exception)r+   r-   rD   file_content
public_keyproviderr   msgs           r5   r   r   p   s   
 ..!1:>>(3K3KLLK!'')) ^^&z~~o'F'FGG F"+">"> !??D(( #? >% " " "J&&:+C+Cj0#66 1,)..00
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"=1
+&'89#N3$.  H T>!!!" ...!GGII
 	

 
0	0	0!@@BB6zNnns6   7B 2D$C#D$#C'	'D$*C'	+4D$#D$connection stringc                 `    	 | |         S # t           $ r d| d| }t          |          d w xY w)NzParameter named "z" is missing from )KeyErrorrQ   )r+   namelocationmessages       r5   r#   r#      sR    +$ + + +HdHHhHH  d*+s   
 #-protocol_argreturnc                 *   |                      d          }t          | |dz   d                   }t          |j                  }d |                                D             }t
                              | d|                   }|r|                    d          |d<   |                    d          |d<   |                    d          |d<   |                    d          |d<   |                    d	          r|                    d	          |d	<   |S )
zA
    Parse the parameters from the protocol argument string.
    ?   Nc                 J    i | ] \  }}|                                 |d          !S )r   )lower).0keyvalues      r5   
<dictcomp>z%_parse_parameters.<locals>.<dictcomp>   s7       ",#u		U1X  r7   r:   r   r   r   r   )findr   r   pathitemscloud_net_naming_pattern_ocimatchgroup)r\   pos
parsed_urlparsed_valuesr+   rk   s         r5   _parse_parametersrp      s    

C
 
 C,sQwyy122JZ_--M 0=0C0C0E0E  J )..|DSD/ABBE 7&+kk/&B&B
?#"'++k":":
;#(;;|#<#<
< !&Z!8!8
:;;w 	7"'++g"6"6Jwr7   c                    t          | dd          }|                     d          }|t          d          |                    d          }|t          |          \  }}|                    d          }||                                }||dk    rt          |          }nu|dk    r5t          j        j        	                                }t          ||	          }n:|d
k    r4t          j        j        
                                }t          ||	          }|                    |          }|j        j        j        }t          j        |                                          S )Nre   z"password" key sectionr   z7OCI Key Vault authentication details were not provided.r   r   r   r   r
   r	   )	secret_id)r#   r    rQ   r   r!   oci_secrets_clientrG   rM   rN   rO   rP   get_secret_bundler&   secret_bundle_contentcontentbase64	b64decodedecode)	argsrr   r   r   r   r-   secret_client_ociget_secret_bundle_response
b64contents	            r5   password_type_oci_vault_hookr~      s   'g/ I XX.//NE
 
 	
  ##L11J,^<<
F $$X..K!''))k]::.z::	0	0	0!GGII.f
 
 
 
0	0	0!@@BB.f
 
 
 "3!D!D "E " " ,0FNJJ''..000r7   c                     | C|                      d          }|d                                                             dd          S d S )N.r`   _-)splitrb   replace)r:   arrs     r5   rE   rE      sE     !!#&&1v||~~%%c3/// ! r7   c                 P    d                     |                                           S )Nr7   )joinry   )streams    r5   r%   r%      s     88F""$$$r7   protocolr,   c                 D    t          |          }t          ||           dS )zE
    Hook for handling parameters stored in an OCI Object store.
    N)rp   r6   )r   r\   r,   r+   s       r5   config_oci_hookr      s'     #<00J
N+++++r7   r   zconfig-ociobject)rV   )#rw   r'   rG   oracledbreurllib.parser   r   r   	from_filerF   rH   rI   oci_client_errorobject_storageObjectStorageClientr"   secretsSecretsClientrs   compilerj   r6   r   r#   strrL   rp   r~   rE   r%   ConnectParamsr   register_password_typeregister_protocolr   r7   r5   <module>r      s~  @   



  				 + + + + + + + +
$>- .B [.   *rzz    
7+ 7+ 7+t/ / /d+ + + +C D    ,%1 %1 %1P0 0 0% % %,,!$,6>6L, , , ,   
,H I I I  - ? ? ? ? ?r7   