blob: c4f14c16791c14db64b79ce3e5cf709060b289d8 [file] [log] [blame]
Zhiyi Zhang440e6a22017-04-14 14:31:37 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento0dc02012021-11-23 22:55:03 -05002/*
Davide Pesavento0d1d11c2022-04-11 22:11:34 -04003 * Copyright (c) 2017-2022, 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 Zhang062be6d2020-10-14 17:13:43 -070022#include "detail/ca-sqlite.hpp"
Davide Pesavento0dc02012021-11-23 22:55:03 -050023
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
Davide Pesavento0dc02012021-11-23 22:55:03 -050028#include <iostream>
29
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040030namespace ndncert::ca {
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070031
Davide Pesavento0dc02012021-11-23 22:55:03 -050032static int
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070033main(int argc, char* argv[])
34{
35 namespace po = boost::program_options;
36 std::string caNameString = "";
Zhiyi Zhang837406d2020-10-05 22:01:31 -070037 po::options_description description(
38 "Usage: ndncert-ca-status [-h] caName\n"
39 "\n"
40 "Options");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070041 description.add_options()
42 ("help,h", "produce help message")
Zhiyi Zhang837406d2020-10-05 22:01:31 -070043 ("caName", po::value<std::string>(&caNameString), "CA Identity Name, e.g., /example");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070044 po::positional_options_description p;
Zhiyi Zhang837406d2020-10-05 22:01:31 -070045 p.add("caName", 1);
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070046 po::variables_map vm;
47 try {
48 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
49 po::notify(vm);
50 }
51 catch (const std::exception& e) {
52 std::cerr << "ERROR: " << e.what() << std::endl;
53 return 1;
54 }
55 if (vm.count("help") != 0) {
56 std::cerr << description << std::endl;
57 return 0;
58 }
Zhiyi Zhang837406d2020-10-05 22:01:31 -070059 if (vm.count("caName") == 0) {
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070060 std::cerr << "ERROR: you must specify a CA identity." << std::endl;
61 return 2;
62 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070063
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070064 CaSqlite storage(Name(caNameString), "");
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070065 std::list<RequestState> requestList;
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070066 requestList = storage.listAllRequests();
67 std::cerr << "The pending requests are :" << std::endl;
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070068 for (const auto& entry : requestList) {
Zhiyi Zhangd93c0bb2020-10-05 22:06:05 -070069 std::cerr << "***************************************\n"
70 << entry
71 << "***************************************\n";
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070072 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070073 return 0;
74}
75
Davide Pesavento0d1d11c2022-04-11 22:11:34 -040076} // namespace ndncert::ca
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070077
78int
79main(int argc, char* argv[])
80{
Davide Pesavento0dc02012021-11-23 22:55:03 -050081 return ndncert::ca::main(argc, argv);
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070082}