blob: 2d0c0f95779326373ba530319f94583e28c415dc [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/*
3 * Copyright (c) 2017-2021, 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
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070030namespace ndncert {
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070031namespace ca {
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070032
Davide Pesavento0dc02012021-11-23 22:55:03 -050033static int
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070034main(int argc, char* argv[])
35{
36 namespace po = boost::program_options;
37 std::string caNameString = "";
Zhiyi Zhang837406d2020-10-05 22:01:31 -070038 po::options_description description(
39 "Usage: ndncert-ca-status [-h] caName\n"
40 "\n"
41 "Options");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070042 description.add_options()
43 ("help,h", "produce help message")
Zhiyi Zhang837406d2020-10-05 22:01:31 -070044 ("caName", po::value<std::string>(&caNameString), "CA Identity Name, e.g., /example");
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070045 po::positional_options_description p;
Zhiyi Zhang837406d2020-10-05 22:01:31 -070046 p.add("caName", 1);
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070047 po::variables_map vm;
48 try {
49 po::store(po::command_line_parser(argc, argv).options(description).positional(p).run(), vm);
50 po::notify(vm);
51 }
52 catch (const std::exception& e) {
53 std::cerr << "ERROR: " << e.what() << std::endl;
54 return 1;
55 }
56 if (vm.count("help") != 0) {
57 std::cerr << description << std::endl;
58 return 0;
59 }
Zhiyi Zhang837406d2020-10-05 22:01:31 -070060 if (vm.count("caName") == 0) {
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070061 std::cerr << "ERROR: you must specify a CA identity." << std::endl;
62 return 2;
63 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070064
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070065 CaSqlite storage(Name(caNameString), "");
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070066 std::list<RequestState> requestList;
Zhiyi Zhangd1d9f5a2020-10-05 18:04:23 -070067 requestList = storage.listAllRequests();
68 std::cerr << "The pending requests are :" << std::endl;
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070069 for (const auto& entry : requestList) {
Zhiyi Zhangd93c0bb2020-10-05 22:06:05 -070070 std::cerr << "***************************************\n"
71 << entry
72 << "***************************************\n";
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070073 }
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070074 return 0;
75}
76
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070077} // namespace ca
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070078} // namespace ndncert
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070079
80int
81main(int argc, char* argv[])
82{
Davide Pesavento0dc02012021-11-23 22:55:03 -050083 return ndncert::ca::main(argc, argv);
Zhiyi Zhang440e6a22017-04-14 14:31:37 -070084}