Skip to content

Commit

Permalink
Added SQLAlchemy Code for X509 Certificates
Browse files Browse the repository at this point in the history
The code for persisting X509 certificates in a database has been added
along with the corresponding unit tests.
  • Loading branch information
rellerreller committed Feb 19, 2016
1 parent 3a4de21 commit 043553c
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 20 deletions.
24 changes: 24 additions & 0 deletions kmip/pie/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,17 @@ class Certificate(CryptographicObject):
names: The list of string names of the Certificate.
"""

__tablename__ = 'certificates'
unique_identifier = Column('uid', Integer,
ForeignKey('crypto_objects.uid'),
primary_key=True)
certificate_type = Column(
'certificate_type', sql.EnumType(enums.CertificateTypeEnum))

__mapper_args__ = {
'polymorphic_identity': 'Certificate'
}

@abstractmethod
def __init__(self, certificate_type, value, masks=None,
name='Certificate'):
Expand Down Expand Up @@ -774,6 +785,15 @@ class X509Certificate(Certificate):
names: The list of string names of the Certificate.
"""

__tablename__ = 'x509_certificates'
unique_identifier = Column('uid', Integer,
ForeignKey('certificates.uid'),
primary_key=True)

__mapper_args__ = {
'polymorphic_identity': 'Certificate'
}

def __init__(self, value, masks=None, name='X.509 Certificate'):
"""
Create an X509Certificate.
Expand Down Expand Up @@ -820,6 +840,10 @@ def __ne__(self, other):
return NotImplemented


event.listen(X509Certificate._names, 'append',
sql.attribute_append_factory("name_index"), retval=False)


class SecretData(CryptographicObject):
"""
The SecretData class of the simplified KMIP object hierarchy.
Expand Down

0 comments on commit 043553c

Please sign in to comment.