mirror of
https://github.com/openkmip/pykmip
synced 2025-12-24 04:04:20 +00:00
Added SQLAlchemy Code for Asymmetric Keys
The code for persisting public and private keys in a database has been added along with the corresponding unit tests.
This commit is contained in:
@@ -388,6 +388,15 @@ class PublicKey(Key):
|
||||
names: The list of string names of the PublicKey.
|
||||
"""
|
||||
|
||||
__tablename__ = 'public_keys'
|
||||
unique_identifier = Column('uid', Integer,
|
||||
ForeignKey('keys.uid'),
|
||||
primary_key=True)
|
||||
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': enums.ObjectType.PUBLIC_KEY
|
||||
}
|
||||
|
||||
def __init__(self, algorithm, length, value,
|
||||
format_type=enums.KeyFormatType.X_509, masks=None,
|
||||
name='Public Key'):
|
||||
@@ -507,6 +516,10 @@ class PublicKey(Key):
|
||||
return NotImplemented
|
||||
|
||||
|
||||
event.listen(PublicKey._names, 'append',
|
||||
sql.attribute_append_factory("name_index"), retval=False)
|
||||
|
||||
|
||||
class PrivateKey(Key):
|
||||
"""
|
||||
The PrivateKey class of the simplified KMIP object hierarchy.
|
||||
@@ -526,6 +539,15 @@ class PrivateKey(Key):
|
||||
to 'Private Key'.
|
||||
"""
|
||||
|
||||
__tablename__ = 'private_keys'
|
||||
unique_identifier = Column('uid', Integer,
|
||||
ForeignKey('keys.uid'),
|
||||
primary_key=True)
|
||||
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': enums.ObjectType.PRIVATE_KEY
|
||||
}
|
||||
|
||||
def __init__(self, algorithm, length, value, format_type, masks=None,
|
||||
name='Private Key'):
|
||||
"""
|
||||
@@ -643,6 +665,10 @@ class PrivateKey(Key):
|
||||
return NotImplemented
|
||||
|
||||
|
||||
event.listen(PrivateKey._names, 'append',
|
||||
sql.attribute_append_factory("name_index"), retval=False)
|
||||
|
||||
|
||||
class Certificate(CryptographicObject):
|
||||
"""
|
||||
The Certificate class of the simplified KMIP object hierarchy.
|
||||
|
||||
Reference in New Issue
Block a user