cert.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Generated by IcedCoffeeScript 1.7.1-c
  2. (function() {
  3. var ArgumentParser, Base, Command, add_option_dict, certs, env, log, version_info,
  4. __hasProp = {}.hasOwnProperty,
  5. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  6. Base = require('./base').Base;
  7. log = require('../log');
  8. ArgumentParser = require('argparse').ArgumentParser;
  9. add_option_dict = require('./argparse').add_option_dict;
  10. version_info = require('../version').version_info;
  11. certs = require('../ca').certs;
  12. env = require('../env').env;
  13. exports.Command = Command = (function(_super) {
  14. __extends(Command, _super);
  15. function Command() {
  16. return Command.__super__.constructor.apply(this, arguments);
  17. }
  18. Command.prototype.OPTS = {
  19. a: {
  20. alias: 'all',
  21. action: 'storeTrue',
  22. help: "list all possible certs in JSON form"
  23. }
  24. };
  25. Command.prototype.add_subcommand_parser = function(scp) {
  26. var name, opts, sub;
  27. opts = {
  28. help: "print out the CA cert the client uses to authorize HTTPS connections"
  29. };
  30. name = "cert";
  31. sub = scp.addParser(name, opts);
  32. add_option_dict(sub, this.OPTS);
  33. sub.addArgument(["host"], {
  34. nargs: '?',
  35. help: "which host to authorize"
  36. });
  37. return [name];
  38. };
  39. Command.prototype.run = function(cb) {
  40. var h;
  41. if (this.argv.all) {
  42. log.console.log(JSON.stringify(certs, null, " "));
  43. } else {
  44. if ((h = this.argv.host) == null) {
  45. h = env().get_host();
  46. log.info("Cert for " + h + " ->");
  47. }
  48. log.console.log(certs[h]);
  49. }
  50. return cb(null);
  51. };
  52. return Command;
  53. })(Base);
  54. }).call(this);