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.

38 lines
1.0 KiB

  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. import cmd
  4. from ca_manager import list_cas, sign_request
  5. class CAManagerShell(cmd.Cmd, object):
  6. intro= """# LILiK CA Manager\n
  7. Welcome to the certification authority shell.
  8. Type help or ? to list commands.
  9. """
  10. prompt= "(CA Manager)> "
  11. def __init__(self, ca_manager):
  12. super(CAManagerShell, self).__init__()
  13. self.ca_manager= ca_manager
  14. def do_ls(self, l):
  15. 'List the available certification authorities: LS'
  16. list_cas(self.ca_manager)
  17. def do_show_ca(self, l):
  18. 'Show certification authority information: SHOW_CA'
  19. raise NotImplementedError()
  20. def do_gen_ssh_ca(self, l):
  21. 'Generate a SSH certification authority: GEN_SSH_CA id name'
  22. try:
  23. [ca_id, ca_name] = l.split(" ", 2)[:2]
  24. self.ca_manager.create_ssh_ca(ca_id, ca_name)
  25. except ValueError:
  26. print "Malformed input: %s" % l
  27. def do_quit(self, l):
  28. 'Quit this shell'
  29. return True