Moving common objects under KeyManager.
Both Barbican and Vault backends have this replicated code. Let's centralize it to reduce code duplication. Change-Id: I365a6d3031695ee369664c00a61816c77792f2e2 Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This commit is contained in:
parent
3ccf918c98
commit
fd01ccc0f5
|
@ -33,11 +33,6 @@ from oslo_utils import excutils
|
||||||
from castellan.common import exception
|
from castellan.common import exception
|
||||||
from castellan.common.objects import key as key_base_class
|
from castellan.common.objects import key as key_base_class
|
||||||
from castellan.common.objects import opaque_data as op_data
|
from castellan.common.objects import opaque_data as op_data
|
||||||
from castellan.common.objects import passphrase
|
|
||||||
from castellan.common.objects import private_key as pri_key
|
|
||||||
from castellan.common.objects import public_key as pub_key
|
|
||||||
from castellan.common.objects import symmetric_key as sym_key
|
|
||||||
from castellan.common.objects import x_509
|
|
||||||
from castellan.i18n import _
|
from castellan.i18n import _
|
||||||
from castellan.key_manager import key_manager
|
from castellan.key_manager import key_manager
|
||||||
|
|
||||||
|
@ -86,14 +81,6 @@ LOG = logging.getLogger(__name__)
|
||||||
class BarbicanKeyManager(key_manager.KeyManager):
|
class BarbicanKeyManager(key_manager.KeyManager):
|
||||||
"""Key Manager Interface that wraps the Barbican client API."""
|
"""Key Manager Interface that wraps the Barbican client API."""
|
||||||
|
|
||||||
_secret_type_dict = {
|
|
||||||
op_data.OpaqueData: 'opaque',
|
|
||||||
passphrase.Passphrase: 'passphrase',
|
|
||||||
pri_key.PrivateKey: 'private',
|
|
||||||
pub_key.PublicKey: 'public',
|
|
||||||
sym_key.SymmetricKey: 'symmetric',
|
|
||||||
x_509.X509: 'certificate'}
|
|
||||||
|
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
self._barbican_client = None
|
self._barbican_client = None
|
||||||
self._base_url = None
|
self._base_url = None
|
||||||
|
|
|
@ -19,6 +19,13 @@ Key manager API
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
|
from castellan.common.objects import opaque_data as op_data
|
||||||
|
from castellan.common.objects import passphrase
|
||||||
|
from castellan.common.objects import private_key as pri_key
|
||||||
|
from castellan.common.objects import public_key as pub_key
|
||||||
|
from castellan.common.objects import symmetric_key as sym_key
|
||||||
|
from castellan.common.objects import x_509
|
||||||
|
|
||||||
|
|
||||||
class KeyManager(object, metaclass=abc.ABCMeta):
|
class KeyManager(object, metaclass=abc.ABCMeta):
|
||||||
"""Base Key Manager Interface
|
"""Base Key Manager Interface
|
||||||
|
@ -27,6 +34,14 @@ class KeyManager(object, metaclass=abc.ABCMeta):
|
||||||
Key Manager is responsible for creating, reading, and deleting keys.
|
Key Manager is responsible for creating, reading, and deleting keys.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_secret_type_dict = {
|
||||||
|
op_data.OpaqueData: "opaque",
|
||||||
|
passphrase.Passphrase: "passphrase",
|
||||||
|
pri_key.PrivateKey: "private",
|
||||||
|
pub_key.PublicKey: "public",
|
||||||
|
sym_key.SymmetricKey: "symmetric",
|
||||||
|
x_509.X509: "certificate"}
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
"""Instantiate a KeyManager object.
|
"""Instantiate a KeyManager object.
|
||||||
|
|
|
@ -33,12 +33,9 @@ from oslo_utils import timeutils
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from castellan.common import exception
|
from castellan.common import exception
|
||||||
from castellan.common.objects import opaque_data as op_data
|
|
||||||
from castellan.common.objects import passphrase
|
|
||||||
from castellan.common.objects import private_key as pri_key
|
from castellan.common.objects import private_key as pri_key
|
||||||
from castellan.common.objects import public_key as pub_key
|
from castellan.common.objects import public_key as pub_key
|
||||||
from castellan.common.objects import symmetric_key as sym_key
|
from castellan.common.objects import symmetric_key as sym_key
|
||||||
from castellan.common.objects import x_509
|
|
||||||
from castellan.i18n import _
|
from castellan.i18n import _
|
||||||
from castellan.key_manager import key_manager
|
from castellan.key_manager import key_manager
|
||||||
|
|
||||||
|
@ -83,14 +80,6 @@ LOG = logging.getLogger(__name__)
|
||||||
class VaultKeyManager(key_manager.KeyManager):
|
class VaultKeyManager(key_manager.KeyManager):
|
||||||
"""Key Manager Interface that wraps the Vault REST API."""
|
"""Key Manager Interface that wraps the Vault REST API."""
|
||||||
|
|
||||||
_secret_type_dict = {
|
|
||||||
op_data.OpaqueData: 'opaque',
|
|
||||||
passphrase.Passphrase: 'passphrase',
|
|
||||||
pri_key.PrivateKey: 'private',
|
|
||||||
pub_key.PublicKey: 'public',
|
|
||||||
sym_key.SymmetricKey: 'symmetric',
|
|
||||||
x_509.X509: 'certificate'}
|
|
||||||
|
|
||||||
def __init__(self, configuration):
|
def __init__(self, configuration):
|
||||||
self._conf = configuration
|
self._conf = configuration
|
||||||
self._conf.register_opts(_vault_opts, group=_VAULT_OPT_GROUP)
|
self._conf.register_opts(_vault_opts, group=_VAULT_OPT_GROUP)
|
||||||
|
|
Loading…
Reference in New Issue