# Path: castellan/common/exception.py
# _FATAL_EXCEPTION_FORMAT_ERRORS = False
# class RedirectException(Exception):
# class CastellanException(Exception):
# class Forbidden(CastellanException):
# class KeyManagerError(CastellanException):
# class ManagedObjectNotFoundError(CastellanException):
# class InvalidManagedObjectDictError(CastellanException):
# class UnknownManagedObjectTypeError(CastellanException):
# class AuthTypeInvalidError(CastellanException):
# class InsufficientCredentialDataError(CastellanException):
#     def __init__(self, url):
#     def __init__(self, message_arg=None, *args, **kwargs):
# 
# Path: castellan/common/objects/key.py
# class Key(managed_object.ManagedObject):
#     def algorithm(self):
#     def bit_length(self):
#     def to_dict(self):
#     def from_dict(cls, dict_fields, id=None, metadata_only=False):
# 
# Path: castellan/common/objects/opaque_data.py
# class OpaqueData(managed_object.ManagedObject):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/i18n.py

# 
# Path: castellan/key_manager/key_manager.py
# class KeyManager(object, metaclass=abc.ABCMeta):
#     def __init__(self, configuration):
#     def create_key(self, context, algorithm, length,
#                    expiration=None, name=None):
#     def create_key_pair(self, context, algorithm, length,
#                         expiration=None, name=None):
#     def store(self, context, managed_object, expiration=None):
#     def get(self, context, managed_object_id, metadata_only=False):
#     def delete(self, context, managed_object_id):
#     def list(self, context, object_type=None, metadata_only=False):
#     def list_options_for_discovery(self):


import calendar
import time
import urllib
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import serialization
from cryptography import x509 as cryptography_x509
from keystoneauth1 import identity
from keystoneauth1 import loading
from keystoneauth1 import service_token
from keystoneauth1 import session
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from castellan.common import exception
from castellan.common.objects import key as key_base_class
from castellan.common.objects import opaque_data as op_data
from castellan.i18n import _
from castellan.key_manager import key_manager
from barbicanclient import client as barbican_client_import
from barbicanclient import exceptions as barbican_exceptions
from oslo_utils import timeutils
        data is not requested until secret.payload is called. If the user
        specifies metadata_only=True, secret.payload is never called,
        preventing unnecessary loading of secret data.

        :param secret: the barbican secret object
        :metadata_only: boolean indicating if the secret bytes should be
                        included in the managed object
        :returns: the castellan object
        """
        secret_type = op_data.OpaqueData
        for castellan_type, barbican_type in self._secret_type_dict.items():
            if barbican_type == secret.secret_type:
                secret_type = castellan_type

        if metadata_only:
            secret_data = None
        else:
            secret_data = self._get_secret_data(secret)

        if secret.secret_ref:
            object_id = self._retrieve_secret_uuid(secret.secret_ref)
        else:
            object_id = None

        # convert created ISO8601 in Barbican to POSIX
        if secret.created:
            time_stamp = timeutils.parse_isotime(
                str(secret.created)).timetuple()
            created = calendar.timegm(time_stamp)


# Path: castellan/common/exception.py
# _FATAL_EXCEPTION_FORMAT_ERRORS = False
# class RedirectException(Exception):
# class CastellanException(Exception):
# class Forbidden(CastellanException):
# class KeyManagerError(CastellanException):
# class ManagedObjectNotFoundError(CastellanException):
# class InvalidManagedObjectDictError(CastellanException):
# class UnknownManagedObjectTypeError(CastellanException):
# class AuthTypeInvalidError(CastellanException):
# class InsufficientCredentialDataError(CastellanException):
#     def __init__(self, url):
#     def __init__(self, message_arg=None, *args, **kwargs):
# 
# Path: castellan/common/objects/key.py
# class Key(managed_object.ManagedObject):
#     def algorithm(self):
#     def bit_length(self):
#     def to_dict(self):
#     def from_dict(cls, dict_fields, id=None, metadata_only=False):
# 
# Path: castellan/common/objects/opaque_data.py
# class OpaqueData(managed_object.ManagedObject):
#     def __init__(self, data, name=None, created=None, id=None):
#     def managed_type(cls):
#     def format(self):
#     def get_encoded(self):
#     def __eq__(self, other):
#     def __ne__(self, other):
# 
# Path: castellan/i18n.py

# 
# Path: castellan/key_manager/key_manager.py
# class KeyManager(object, metaclass=abc.ABCMeta):
#     def __init__(self, configuration):
#     def create_key(self, context, algorithm, length,
#                    expiration=None, name=None):
#     def create_key_pair(self, context, algorithm, length,
#                         expiration=None, name=None):
#     def store(self, context, managed_object, expiration=None):
#     def get(self, context, managed_object_id, metadata_only=False):
#     def delete(self, context, managed_object_id):
#     def list(self, context, object_type=None, metadata_only=False):
#     def list_options_for_discovery(self):


# Path: castellan/key_manager/barbican_key_manager.py
import calendar
import time
import urllib
from cryptography.hazmat import backends
from cryptography.hazmat.primitives import serialization
from cryptography import x509 as cryptography_x509
from keystoneauth1 import identity
from keystoneauth1 import loading
from keystoneauth1 import service_token
from keystoneauth1 import session
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from castellan.common import exception
from castellan.common.objects import key as key_base_class
from castellan.common.objects import opaque_data as op_data
from castellan.i18n import _
from castellan.key_manager import key_manager
from barbicanclient import client as barbican_client_import
from barbicanclient import exceptions as barbican_exceptions
from oslo_utils import timeutils

        data is not requested until secret.payload is called. If the user
        specifies metadata_only=True, secret.payload is never called,
        preventing unnecessary loading of secret data.

        :param secret: the barbican secret object
        :metadata_only: boolean indicating if the secret bytes should be
                        included in the managed object
        :returns: the castellan object
        """
        secret_type = op_data.OpaqueData
        for castellan_type, barbican_type in self._secret_type_dict.items():
            if barbican_type == secret.secret_type:
                secret_type = castellan_type

        if metadata_only:
            secret_data = None
        else:
            secret_data = self._get_secret_data(secret)

        if secret.secret_ref:
            object_id = self._retrieve_secret_uuid(secret.secret_ref)
        else:
            object_id = None

        # convert created ISO8601 in Barbican to POSIX
        if secret.created:
            time_stamp = timeutils.parse_isotime(
                str(secret.created)).timetuple()
            created = calendar.timegm(time_stamp)


        if issubclass(secret_type, key_base_class.Key):