a fI @sddlmZddlmZddlmZddlmZddlm Z ddl Z ddl Z ddlmZddlZddlZddlZe jjdgggd dd d d d ddZGdddeZGdddeZGdddeZGdddeZGdddeZdS))x509)default_backend)requests) HTTPError) ServiceErrorN)sixT)ii)Zservice_error_checkZservice_error_retry_configZservice_error_retry_on_any_5xxZ$retry_max_wait_between_calls_secondsZretry_base_sleep_time_secondsZretry_exponential_growth_factorZtotal_elapsed_time_secondsc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)AbstractCertificateRetrievercKsdddd|_dS)N) certificateprivate_key_pem private_keycertificate_and_private_keyselfkwargsrB/usr/lib/python3.9/site-packages/oci/auth/certificate_retriever.py__init__1sz%AbstractCertificateRetriever.__init__cCs tddSNz Subclasses should implement thisNotImplementedErrorrrrrrefresh9sz$AbstractCertificateRetriever.refreshcCs tddSrrrrrrget_certificate_and_private_key=szrr'Qs      Fr'csPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)PEMStringCertificateRetrievera? A certificate retriever which is provided PEM format strings directly. This retriever is non-refreshable, and calling refresh() is a no-op. :param str certificate_pem: The PEM-formatted string of the certificate. This is mandatory. :param str private_key_pem (optional): The PEM-formatted string of the private key corresponding to certificate_pem (if any). :param str passphrase (optional): The passphrase of the private key (if any). **Note:** This class is used internally, it is not recommended for user's direct use. c sddl}tt|d|vr&tdt|dtjrL|dd|j d<n|d|j d<d|vr|drt|dtjr|dd|j d<n|d|j d<d|vr|dr|dd}nd}|j |j d||j d<dS) Nrcertificate_pemz6certificate_pem must be supplied as a keyword argumentr+rrr)r) rXr-rrrr.r6rr7r8rrhri)rrrlr)r>rrr4s$z&PEMStringCertificateRetriever.__init__cCsdS)z Since these are just the string, there is no refresh as such. A new object should be created if the strings change NrrrrrrQsz%PEMStringCertificateRetriever.refreshcCs |jSrC)rrErrrrrXsz=PEMStringCertificateRetriever.get_certificate_and_private_keycCst|jdtS)rFr)rrGrrrrrrr ^szrrr$s rrcs(eZdZdZfddZddZZS)FileBasedCertificateRetrievera/ A specialization of PEMStringCertificateRetriever which reads certificates from a file. This retriever is non-refreshable, and calling refresh() is a no-op. :param str certificate_file_path: The file path from which to retrieve a certificate. It is assumed that what we retrieve is the PEM-formatted string for the certificate. This is mandatory :param str private_key_pem_file_path (optional): The file path from which to retrieve the private key corresponding to certificate_file_path (if any). It is assumed that what we retrieve is the PEM-formatted string for the private key. :param str passphrase (optional): The passphrase of the private key (if any). **Note:** This class is used internally, it is not recommended for user's direct use. c sbd|vrtdd|vr(||d}nd}||d||dd}tt|jfi|dS)NZcertificate_file_pathzrrrs z&FileBasedCertificateRetriever.__init__cCsHtj|}t|dd}|}Wdn1s:0Y|S)Nrb)mode)ospath expanduseropenreadre)rfilenamefZ cert_datarrrrus *z2FileBasedCertificateRetriever._load_data_from_file)r$r%r&rprrurqrrr>rrtws rtcseZdZdfdd ZZS)rkrNcs,||_||_tt|d|j|jddS)NzTInvalid certificate returned from instance metadata. Expected a PEM-formatted string)messagerVrW)rWrVr-rkr)rrVrWr>rrrs z4InvalidCertificateFromInstanceMetadataError.__init__)rN)r$r%r&rrqrrr>rrksrk)Z cryptographyrZcryptography.hazmat.backendsrZ oci._vendorrZoci._vendor.requests.exceptionsrZoci.exceptionsrZ oci.retryrlZos.pathrxrr9r1r[ZretryZRetryStrategyBuilderZadd_max_attemptsZadd_total_elapsed_timeZget_retry_strategyZ:INSTANCE_METADATA_URL_CERTIFICATE_RETRIEVER_RETRY_STRATEGYobjectrr'rrrt Exceptionrkrrrrs6        !TS+