Codebase list python-castellan / fd01ccc
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> Moisés Guimarães de Medeiros 4 years ago
3 changed file(s) with 15 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
3232 from castellan.common import exception
3333 from castellan.common.objects import key as key_base_class
3434 from castellan.common.objects import opaque_data as op_data
35 from castellan.common.objects import passphrase
36 from castellan.common.objects import private_key as pri_key
37 from castellan.common.objects import public_key as pub_key
38 from castellan.common.objects import symmetric_key as sym_key
39 from castellan.common.objects import x_509
4035 from castellan.i18n import _
4136 from castellan.key_manager import key_manager
4237
8479
8580 class BarbicanKeyManager(key_manager.KeyManager):
8681 """Key Manager Interface that wraps the Barbican client API."""
87
88 _secret_type_dict = {
89 op_data.OpaqueData: 'opaque',
90 passphrase.Passphrase: 'passphrase',
91 pri_key.PrivateKey: 'private',
92 pub_key.PublicKey: 'public',
93 sym_key.SymmetricKey: 'symmetric',
94 x_509.X509: 'certificate'}
9582
9683 def __init__(self, configuration):
9784 self._barbican_client = None
1818
1919 import abc
2020
21 from castellan.common.objects import opaque_data as op_data
22 from castellan.common.objects import passphrase
23 from castellan.common.objects import private_key as pri_key
24 from castellan.common.objects import public_key as pub_key
25 from castellan.common.objects import symmetric_key as sym_key
26 from castellan.common.objects import x_509
27
2128
2229 class KeyManager(object, metaclass=abc.ABCMeta):
2330 """Base Key Manager Interface
2532 A Key Manager is responsible for managing encryption keys for volumes. A
2633 Key Manager is responsible for creating, reading, and deleting keys.
2734 """
35
36 _secret_type_dict = {
37 op_data.OpaqueData: "opaque",
38 passphrase.Passphrase: "passphrase",
39 pri_key.PrivateKey: "private",
40 pub_key.PublicKey: "public",
41 sym_key.SymmetricKey: "symmetric",
42 x_509.X509: "certificate"}
2843
2944 @abc.abstractmethod
3045 def __init__(self, configuration):
3232 import requests
3333
3434 from castellan.common import exception
35 from castellan.common.objects import opaque_data as op_data
36 from castellan.common.objects import passphrase
3735 from castellan.common.objects import private_key as pri_key
3836 from castellan.common.objects import public_key as pub_key
3937 from castellan.common.objects import symmetric_key as sym_key
40 from castellan.common.objects import x_509
4138 from castellan.i18n import _
4239 from castellan.key_manager import key_manager
4340
8279 class VaultKeyManager(key_manager.KeyManager):
8380 """Key Manager Interface that wraps the Vault REST API."""
8481
85 _secret_type_dict = {
86 op_data.OpaqueData: 'opaque',
87 passphrase.Passphrase: 'passphrase',
88 pri_key.PrivateKey: 'private',
89 pub_key.PublicKey: 'public',
90 sym_key.SymmetricKey: 'symmetric',
91 x_509.X509: 'certificate'}
92
9382 def __init__(self, configuration):
9483 self._conf = configuration
9584 self._conf.register_opts(_vault_opts, group=_VAULT_OPT_GROUP)