Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
tylerliu | 182bc53 | 2020-09-25 01:54:45 -0700 | [diff] [blame] | 3 | * Copyright (c) 2017-2020, Regents of the University of California. |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndncert, a certificate management system based on NDN. |
| 6 | * |
| 7 | * ndncert is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ndncert authors and contributors. |
| 19 | */ |
| 20 | |
| 21 | #include "ca-module.hpp" |
Zhiyi Zhang | 8bd8e5b | 2020-09-29 17:40:40 -0700 | [diff] [blame] | 22 | #include "ca-storage-detail/ca-sqlite.hpp" |
Zhiyi Zhang | b6fab0f | 2017-09-21 16:26:27 -0700 | [diff] [blame] | 23 | #include <iostream> |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 24 | #include <boost/program_options/options_description.hpp> |
| 25 | #include <boost/program_options/variables_map.hpp> |
| 26 | #include <boost/program_options/parsers.hpp> |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace ndncert { |
| 30 | |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 31 | int |
| 32 | main(int argc, char* argv[]) |
| 33 | { |
| 34 | namespace po = boost::program_options; |
| 35 | std::string caNameString = ""; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 36 | po::options_description description( |
| 37 | "Usage: ndncert-ca-status [-h] caName\n" |
| 38 | "\n" |
| 39 | "Options"); |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 40 | description.add_options() |
| 41 | ("help,h", "produce help message") |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 42 | ("caName", po::value<std::string>(&caNameString), "CA Identity Name, e.g., /example"); |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 43 | po::positional_options_description p; |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 44 | p.add("caName", 1); |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 45 | po::variables_map vm; |
| 46 | try { |
| 47 | po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm); |
| 48 | po::notify(vm); |
| 49 | } |
| 50 | catch (const std::exception& e) { |
| 51 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 52 | return 1; |
| 53 | } |
| 54 | if (vm.count("help") != 0) { |
| 55 | std::cerr << description << std::endl; |
| 56 | return 0; |
| 57 | } |
Zhiyi Zhang | 837406d | 2020-10-05 22:01:31 -0700 | [diff] [blame] | 58 | if (vm.count("caName") == 0) { |
Zhiyi Zhang | d1d9f5a | 2020-10-05 18:04:23 -0700 | [diff] [blame] | 59 | std::cerr << "ERROR: you must specify a CA identity." << std::endl; |
| 60 | return 2; |
| 61 | } |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 62 | |
Zhiyi Zhang | d1d9f5a | 2020-10-05 18:04:23 -0700 | [diff] [blame] | 63 | CaSqlite storage(Name(caNameString), ""); |
tylerliu | 8704d03 | 2020-06-23 10:18:15 -0700 | [diff] [blame] | 64 | std::list<CaState> requestList; |
Zhiyi Zhang | d1d9f5a | 2020-10-05 18:04:23 -0700 | [diff] [blame] | 65 | requestList = storage.listAllRequests(); |
| 66 | std::cerr << "The pending requests are :" << std::endl; |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 67 | for (const auto& entry : requestList) { |
Zhiyi Zhang | d93c0bb | 2020-10-05 22:06:05 -0700 | [diff] [blame^] | 68 | std::cerr << "***************************************\n" |
| 69 | << entry |
| 70 | << "***************************************\n"; |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 71 | } |
Zhiyi Zhang | 440e6a2 | 2017-04-14 14:31:37 -0700 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | } // namespace ndncert |
| 76 | } // namespace ndn |
| 77 | |
| 78 | int |
| 79 | main(int argc, char* argv[]) |
| 80 | { |
| 81 | return ndn::ndncert::main(argc, argv); |
| 82 | } |