aboutsummaryrefslogtreecommitdiff
path: root/rpki/fields.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-10-19 03:36:42 +0000
committerRob Austein <sra@hactrn.net>2015-10-19 03:36:42 +0000
commit7f5e75188ad4527e3c3425a155dfed0847a389dd (patch)
tree400301cae01f51141e380664cf0b382b8204a00d /rpki/fields.py
parent7ab6040f7eb05a7ac4424e0294d228256e9a64dd (diff)
Amputate old SQL code out of rpkid with a fire axe, replacing it with
Django ORM. Duct tape and bailing wire everywhere, much clean-up left to do, but basic "make yamltest" suite runs. Much of the clean-up isn't worth doing until after revamping the I/O system, as it'll all change again at that point anyway. svn path=/branches/tk705/; revision=6127
Diffstat (limited to 'rpki/fields.py')
-rw-r--r--rpki/fields.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/rpki/fields.py b/rpki/fields.py
index 4a826f4e..6c71ac35 100644
--- a/rpki/fields.py
+++ b/rpki/fields.py
@@ -47,6 +47,7 @@ class EnumField(models.PositiveSmallIntegerField):
def __init__(self, *args, **kwargs):
if isinstance(kwargs.get("choices"), (tuple, list)) and isinstance(kwargs["choices"][0], (str, unicode)):
kwargs["choices"] = tuple(enumerate(kwargs["choices"], 1))
+ # Might need something here to handle string-valued default parameter
models.PositiveSmallIntegerField.__init__(self, *args, **kwargs)
self.enum_i2s = dict(self.flatchoices)
self.enum_s2i = dict((v, k) for k, v in self.flatchoices)
@@ -148,6 +149,9 @@ class DERField(BlobField):
__metaclass__ = models.SubfieldBase
def to_python(self, value):
+ if value is not None and not isinstance(value, (self.rpki_type, str)):
+ logger.warning("Why am I now seeing a %r instead of str or %r in the %r rpki.fields.DERField.to_python() method?",
+ type(value), self.rpki_type, type(self))
assert value is None or isinstance(value, (self.rpki_type, str))
if isinstance(value, str):
return self.rpki_type(DER = value)
@@ -165,10 +169,16 @@ class CertificateField(DERField):
description = "X.509 certificate"
rpki_type = rpki.x509.X509
-class KeyField(DERField):
+class RSAPrivateKeyField(DERField):
description = "RSA keypair"
rpki_type = rpki.x509.RSA
+KeyField = RSAPrivateKeyField # XXX backwards compatability
+
+class PublicKeyField(DERField):
+ description = "RSA keypair"
+ rpki_type = rpki.x509.PublicKey
+
class CRLField(DERField):
description = "Certificate Revocation List"
rpki_type = rpki.x509.CRL