# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# NO_URLS_MATCHED_GENERIC = (NO_URLS_MATCHED_PREFIX +
#                            '. Do the files you\'re operating on exist?')
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# class AbortException(StandardError):
# class CommandException(StandardError):
# class ControlCException(Exception):
# class GcloudStorageTranslationError(Exception):
# class HashMismatchException(Exception):
# class IamChOnResourceWithConditionsException(Exception):
# class InvalidUrlError(Exception):
# class ExternalBinaryError(Exception):
#   def __init__(self, reason):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, reason, informational=False):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
# 
# Path: gslib/utils/execution_util.py
# def ExecuteExternalCommand(command_and_flags):


import atexit
import json
import os
import gslib
from boto import config
from gslib import exception
from gslib.utils import execution_util

    # Generates certificate and deletes it afterwards.
    atexit.register(self._unprovision_client_cert)
    self.client_cert_path = os.path.join(gslib.GSUTIL_DIR, 'caa_cert.pem')
    try:
      # Certs provisioned using endpoint verification are stored as a
      # single file holding both the public certificate and the private key.
      self._provision_client_cert(self.client_cert_path)
    except CertProvisionError as e:
      self.logger.error('Failed to provision client certificate: %s' % e)

  def _provision_client_cert(self, cert_path):
    """Executes certificate provider to obtain client certificate and keys."""
    cert_command_string = config.get('Credentials', 'cert_provider_command',
                                     None)
    if cert_command_string:
      cert_command = cert_command_string.split(' ')
    else:
      # Load the default certificate provider if sit is not provided by user.
      cert_command = _default_command()

    try:
      command_stdout_string, _ = execution_util.ExecuteExternalCommand(
          cert_command)

      sections = _split_pem_into_sections(command_stdout_string, self.logger)
      with open(cert_path, 'w+') as f:
        f.write(sections['CERTIFICATE'])
        f.write(sections['ENCRYPTED PRIVATE KEY'])
      self.client_cert_password = sections['PASSPHRASE'].splitlines()[1]

# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# NO_URLS_MATCHED_GENERIC = (NO_URLS_MATCHED_PREFIX +
#                            '. Do the files you\'re operating on exist?')
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# class AbortException(StandardError):
# class CommandException(StandardError):
# class ControlCException(Exception):
# class GcloudStorageTranslationError(Exception):
# class HashMismatchException(Exception):
# class IamChOnResourceWithConditionsException(Exception):
# class InvalidUrlError(Exception):
# class ExternalBinaryError(Exception):
#   def __init__(self, reason):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, reason, informational=False):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
#   def __str__(self):
#   def __init__(self, message):
#   def __repr__(self):
# 
# Path: gslib/utils/execution_util.py
# def ExecuteExternalCommand(command_and_flags):


# Path: gslib/context_config.py
import atexit
import json
import os
import gslib
from boto import config
from gslib import exception
from gslib.utils import execution_util


    # Generates certificate and deletes it afterwards.
    atexit.register(self._unprovision_client_cert)
    self.client_cert_path = os.path.join(gslib.GSUTIL_DIR, 'caa_cert.pem')
    try:
      # Certs provisioned using endpoint verification are stored as a
      # single file holding both the public certificate and the private key.
      self._provision_client_cert(self.client_cert_path)
    except CertProvisionError as e:
      self.logger.error('Failed to provision client certificate: %s' % e)

  def _provision_client_cert(self, cert_path):
    """Executes certificate provider to obtain client certificate and keys."""
    cert_command_string = config.get('Credentials', 'cert_provider_command',
                                     None)
    if cert_command_string:
      cert_command = cert_command_string.split(' ')
    else:
      # Load the default certificate provider if sit is not provided by user.
      cert_command = _default_command()

    try:
      command_stdout_string, _ = execution_util.ExecuteExternalCommand(
          cert_command)

      sections = _split_pem_into_sections(command_stdout_string, self.logger)
      with open(cert_path, 'w+') as f:
        f.write(sections['CERTIFICATE'])
        f.write(sections['ENCRYPTED PRIVATE KEY'])
      self.client_cert_password = sections['PASSPHRASE'].splitlines()[1]

    except (exception.ExternalBinaryError, OSError) as e: