Browse Source

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>
tags/3.0.0
Moisés Guimarães de Medeiros 4 months ago
parent
commit
fd01ccc0f5
3 changed files with 15 additions and 24 deletions
  1. +0
    -13
      castellan/key_manager/barbican_key_manager.py
  2. +15
    -0
      castellan/key_manager/key_manager.py
  3. +0
    -11
      castellan/key_manager/vault_key_manager.py

+ 0
- 13
castellan/key_manager/barbican_key_manager.py View File

@@ -33,11 +33,6 @@ 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.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.key_manager import key_manager

@@ -86,14 +81,6 @@ LOG = logging.getLogger(__name__)
class BarbicanKeyManager(key_manager.KeyManager):
"""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):
self._barbican_client = None
self._base_url = None


+ 15
- 0
castellan/key_manager/key_manager.py View File

@@ -19,6 +19,13 @@ Key manager API

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):
"""Base Key Manager Interface
@@ -27,6 +34,14 @@ class KeyManager(object, metaclass=abc.ABCMeta):
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
def __init__(self, configuration):
"""Instantiate a KeyManager object.


+ 0
- 11
castellan/key_manager/vault_key_manager.py View File

@@ -33,12 +33,9 @@ from oslo_utils import timeutils
import requests

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 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.key_manager import key_manager

@@ -83,14 +80,6 @@ LOG = logging.getLogger(__name__)
class VaultKeyManager(key_manager.KeyManager):
"""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):
self._conf = configuration
self._conf.register_opts(_vault_opts, group=_VAULT_OPT_GROUP)


Loading…
Cancel
Save