Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 7 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 8 | * |
| 9 | * This file licensed under New BSD License. See COPYING for detailed information about |
| 10 | * ndn-cxx library copyright, permissions, and redistribution restrictions. |
| 11 | * |
| 12 | * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/> |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include "ndnsec-util.hpp" |
| 16 | #include "ndnsec-list.hpp" |
| 17 | #include "ndnsec-get-default.hpp" |
| 18 | #include "ndnsec-set-default.hpp" |
| 19 | #include "ndnsec-key-gen.hpp" |
| 20 | #include "ndnsec-dsk-gen.hpp" |
| 21 | #include "ndnsec-sign-req.hpp" |
| 22 | #include "ndnsec-cert-gen.hpp" |
| 23 | #include "ndnsec-cert-dump.hpp" |
| 24 | #include "ndnsec-cert-install.hpp" |
| 25 | #include "ndnsec-export.hpp" |
| 26 | #include "ndnsec-import.hpp" |
| 27 | #include "ndnsec-delete.hpp" |
| 28 | #include "ndnsec-sig-verify.hpp" |
| 29 | #include "ndnsec-set-acl.hpp" |
| 30 | #include "ndnsec-unlock-tpm.hpp" |
| 31 | #include "ndnsec-op-tool.hpp" |
| 32 | |
| 33 | using namespace ndn; |
| 34 | |
| 35 | std::string ndnsec_helper("\ |
| 36 | help Show all commands.\n\ |
| 37 | list Display information in PublicInfo.\n\ |
| 38 | get-default Get default setting info.\n\ |
| 39 | set-default Configure default setting.\n\ |
| 40 | key-gen Generate a Key-Signing-Key for an identity.\n\ |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 41 | sign-req Generate a certificate signing request.\n\ |
| 42 | cert-gen Generate an identity certificate.\n\ |
| 43 | cert-dump Dump a certificate from PublicInfo.\n\ |
| 44 | cert-install Install a certificate into PublicInfo.\n\ |
Yingdi Yu | 5c1f841 | 2014-03-25 11:49:47 -0700 | [diff] [blame] | 45 | delete Delete identity/key/certificate.\n\ |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 46 | export Export an identity package.\n\ |
| 47 | import Import an identity package.\n\ |
| 48 | sig-verify Verify the signature of a Data packet.\n\ |
| 49 | set-acl Configure ACL of a private key.\n\ |
| 50 | unlock-tpm Unlock Tpm.\n\ |
| 51 | op-tool Operator tool.\n\ |
Yingdi Yu | 05842f2 | 2014-04-15 19:21:56 -0700 | [diff] [blame] | 52 | "); |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 53 | |
Yingdi Yu | 05842f2 | 2014-04-15 19:21:56 -0700 | [diff] [blame] | 54 | int |
Yingdi Yu | 5c1f841 | 2014-03-25 11:49:47 -0700 | [diff] [blame] | 55 | main(int argc, char** argv) |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 56 | { |
Yingdi Yu | b61f540 | 2014-02-26 17:46:11 -0800 | [diff] [blame] | 57 | if (argc < 2) |
Yingdi Yu | f8fc8de | 2014-02-25 15:45:39 -0800 | [diff] [blame] | 58 | { |
| 59 | std::cerr << ndnsec_helper << std::endl; |
| 60 | return 1; |
| 61 | } |
| 62 | |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 63 | std::string command(argv[1]); |
Yingdi Yu | b61f540 | 2014-02-26 17:46:11 -0800 | [diff] [blame] | 64 | |
| 65 | try |
| 66 | { |
| 67 | if (command == "help") { std::cerr << ndnsec_helper << std::endl; } |
| 68 | else if (command == "list") { return ndnsec_list(argc - 1, argv + 1); } |
| 69 | else if (command == "get-default") { return ndnsec_get_default(argc - 1, argv + 1); } |
| 70 | else if (command == "set-default") { return ndnsec_set_default(argc - 1, argv + 1); } |
| 71 | else if (command == "key-gen") { return ndnsec_key_gen(argc - 1, argv + 1); } |
| 72 | else if (command == "sign-req") { return ndnsec_sign_req(argc - 1, argv + 1); } |
| 73 | else if (command == "cert-gen") { return ndnsec_cert_gen(argc - 1, argv + 1); } |
| 74 | else if (command == "cert-dump") { return ndnsec_cert_dump(argc - 1, argv + 1); } |
| 75 | else if (command == "cert-install") { return ndnsec_cert_install(argc - 1, argv + 1); } |
| 76 | else if (command == "delete") { return ndnsec_delete(argc - 1, argv + 1); } |
| 77 | else if (command == "export") { return ndnsec_export(argc - 1, argv + 1); } |
| 78 | else if (command == "import") { return ndnsec_import(argc - 1, argv + 1); } |
| 79 | else if (command == "sig-verify") { return ndnsec_sig_verify(argc - 1, argv + 1); } |
| 80 | else if (command == "set-acl") { return ndnsec_set_acl(argc - 1, argv + 1); } |
| 81 | else if (command == "unlock-tpm") { return ndnsec_unlock_tpm(argc - 1, argv + 1); } |
| 82 | else if (command == "op-tool") { return ndnsec_op_tool(argc - 1, argv + 1); } |
| 83 | else { |
| 84 | std::cerr << ndnsec_helper << std::endl; |
| 85 | return 1; |
| 86 | } |
| 87 | } |
| 88 | catch (const std::runtime_error& e) |
| 89 | { |
| 90 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 91 | return 1; |
| 92 | } |
Yingdi Yu | 8d7468f | 2014-02-21 14:49:45 -0800 | [diff] [blame] | 93 | |
| 94 | return 0; |
| 95 | } |