a NfF@sddlmZddlmZddlmZddlZddlZ ddlm Z ddl Z ddl Z ddl Z ejZGdddeZGdd d eZGd d d eZGd d d eZGdddeZdS))x509)default_backend)requestsN)sixc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)AbstractCertificateRetrievercKsdddd|_dS)N) certificateprivate_key_pem private_keycertificate_and_private_keyselfkwargsr/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/oci/auth/certificate_retriever.py__init__(sz%AbstractCertificateRetriever.__init__cCs tddSNz Subclasses should implement thisNotImplementedErrorr rrrrefresh0sz$AbstractCertificateRetriever.refreshcCs tddSrrrrrrget_certificate_and_private_key4szrrHs      @rcsPeZdZdZfddZddZddZdd 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 ) r\r'ryrr(r5rr6r7r rkrl)r rrpr"r>rrr%s$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 NrrrrrrBsz%PEMStringCertificateRetriever.refreshcCs |jSrD)r rFrrrrrIsz=PEMStringCertificateRetriever.get_certificate_and_private_keycCst|jdtS)rHr)rrIr rrrrrrOszrrys rycs(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)Ncertificate_file_pathzrrrzs z&FileBasedCertificateRetriever.__init__cCsHtj|}t|dd}|}Wdn1s:0Y|S)Nrb)mode)ospath expanduseropenreadrh)r filenamef cert_datarrrr~s *z2FileBasedCertificateRetriever._load_data_from_file)rrrrwrr~rxrrr>rr{hs r{cseZdZdfdd ZZS)rorNcs,||_||_tt|d|j|jddS)NzTInvalid certificate returned from instance metadata. Expected a PEM-formatted string)messagerZr[)r[rZr'ror)r rZr[r>rrrs z4InvalidCertificateFromInstanceMetadataError.__init__)rN)rrrrrxrrr>rrosro) cryptographyrcryptography.hazmat.backendsr oci._vendorr oci.retryrpos.pathrrr8r+r_retryRetryStrategyBuilderadd_max_attemptsadd_total_elapsed_timeget_retry_strategy:INSTANCE_METADATA_URL_CERTIFICATE_RETRIEVER_RETRY_STRATEGYobjectrrryr{ Exceptionrorrrrs    !NS+