blob: 4b75cb9a485a84dbc0d9a42de0d6630daceab714 [file] [log] [blame]
Zhiyi Zhang440e6a22017-04-14 14:31:37 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
tylerliu182bc532020-09-25 01:54:45 -07003 * Copyright (c) 2017-2020, Regents of the University of California.
Zhiyi Zhang440e6a22017-04-14 14:31:37 -07004 *
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 Zhang8bd8e5b2020-09-29 17:40:40 -070022#include "ca-storage-detail/ca-sqlite.hpp"
Zhiyi Zhangb6fab0f2017-09-21 16:26:27 -070023#include <iostream>
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070024#include <boost/program_options/options_description.hpp>
25#include <boost/program_options/variables_map.hpp>
26#include <boost/program_options/parsers.hpp>
27
28namespace ndn {
29namespace ndncert {
30
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070031int
32main(int argc, char* argv[])
33{
34 namespace po = boost::program_options;
35 std::string caNameString = "";
Zhiyi Zhang837406d2020-10-05 22:01:31 -070036 po::options_description description(
37 "Usage: ndncert-ca-status [-h] caName\n"
38 "\n"
39 "Options");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070040 description.add_options()
41 ("help,h", "produce help message")
Zhiyi Zhang837406d2020-10-05 22:01:31 -070042 ("caName", po::value<std::string>(&caNameString), "CA Identity Name, e.g., /example");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070043 po::positional_options_description p;
Zhiyi Zhang837406d2020-10-05 22:01:31 -070044 p.add("caName", 1);
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070045 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 Zhang837406d2020-10-05 22:01:31 -070058 if (vm.count("caName") == 0) {
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070059 std::cerr << "ERROR: you must specify a CA identity." << std::endl;
60 return 2;
61 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070062
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070063 CaSqlite storage(Name(caNameString), "");
tylerliu8704d032020-06-23 10:18:15 -070064 std::list<CaState> requestList;
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070065 requestList = storage.listAllRequests();
66 std::cerr << "The pending requests are :" << std::endl;
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070067 for (const auto& entry : requestList) {
Zhiyi Zhangd93c0bb2020-10-05 22:06:05 -070068 std::cerr << "***************************************\n"
69 << entry
70 << "***************************************\n";
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070071 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070072 return 0;
73}
74
75} // namespace ndncert
76} // namespace ndn
77
78int
79main(int argc, char* argv[])
80{
81 return ndn::ndncert::main(argc, argv);
82}