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.

47 lines
947 B

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from peewee import *
  4. import os
  5. import os.path
  6. from paths import *
  7. __doc__= """
  8. Module of base classes to handle authorities
  9. """
  10. class Authority(Model):
  11. request_allowed = []
  12. # data stored in the database
  13. ca_id = CharField(
  14. index = True,
  15. unique = True,
  16. )
  17. name = CharField(
  18. index = True,
  19. help_text = 'authority descriptive name',
  20. )
  21. serial = IntegerField(
  22. help_text = 'last certificate serial number',
  23. )
  24. def __bool__(self):
  25. return os.path.exists(self.path)
  26. @property
  27. def path(self):
  28. return os.path.join(MANAGER_PATH, self.ca_id)
  29. def generate(self):
  30. raise NotImplementedError()
  31. def sign(self, request):
  32. raise NotImplementedError()
  33. def __repr__(self):
  34. return ( "%s %s" % ( self.__class__.__name__, self.ca_id ) )