Easy CA management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from playhouse.gfk import *
  4. import os
  5. import json
  6. from models import customModel
  7. from paths import *
  8. class Certificate(customModel.CustomModel):
  9. """
  10. """
  11. authority_type = CharField(null=True)
  12. authority_id = IntegerField(null=True)
  13. authority = GFKField('authority_type', 'authority_id')
  14. cert_id = CharField(
  15. index = True,
  16. unique = True,
  17. help_text = 'id shared with the sign request',
  18. )
  19. date_issued = DateTimeField(
  20. help_text = 'certificate\'s issue date',
  21. )
  22. receiver = CharField(
  23. help_text = 'hostname or list of user for this certificate',
  24. )
  25. serial_number = IntegerField(
  26. help_text = 'certificate\'s progressive number',
  27. )
  28. validity_interval = CharField(
  29. help_text = 'how long will the certificate be valid',
  30. )
  31. path = CharField(
  32. help_text = 'certificate\'s path on filesystem',
  33. )
  34. def __repr__(self):
  35. msg = """<%s:%s> for %s
  36. signed %s by %s"""
  37. return (
  38. msg % (self.__class__.__name__, self.cert_id, self.receiver, self.date_issued, self.authority)
  39. )
  40. def __bool__(self):
  41. return os.path.exists(self.path)