| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| /* |
| * Copyright (c) 2014-2021, Regents of the University of California |
| * |
| * NAC library is free software: you can redistribute it and/or modify it under the |
| * terms of the GNU Lesser General Public License as published by the Free Software |
| * Foundation, either version 3 of the License, or (at your option) any later version. |
| * |
| * NAC library is distributed in the hope that it will be useful, but WITHOUT ANY |
| * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| * |
| * You should have received copies of the GNU General Public License and GNU Lesser |
| * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| * <http://www.gnu.org/licenses/>. |
| * |
| * See AUTHORS.md for complete list of NAC library authors and contributors. |
| */ |
| |
| #ifndef NAC_TOOLS_NDN_NAC_NDN_NAC_HPP |
| #define NAC_TOOLS_NDN_NAC_NDN_NAC_HPP |
| |
| #include "common.hpp" |
| |
| #include <iostream> |
| |
| #include <boost/program_options/options_description.hpp> |
| #include <boost/program_options/parsers.hpp> |
| #include <boost/program_options/variables_map.hpp> |
| |
| #include <ndn-cxx/util/dummy-client-face.hpp> |
| #include <ndn-cxx/util/exception.hpp> |
| #include <ndn-cxx/util/io.hpp> |
| |
| namespace ndn { |
| namespace nac { |
| |
| int |
| nac_dump_kek(int argc, char** argv); |
| |
| int |
| nac_add_member(int argc, char** argv); |
| |
| inline Certificate |
| loadCertificate(const std::string& fileName) |
| { |
| try { |
| if (fileName == "-") { |
| return io::loadTlv<Certificate>(std::cin, io::BASE64); |
| } |
| |
| std::ifstream file(fileName); |
| if (!file) { |
| NDN_THROW(std::runtime_error("Cannot open '" + fileName + "'")); |
| } |
| return io::loadTlv<Certificate>(file, io::BASE64); |
| } |
| catch (const io::Error& e) { |
| NDN_THROW_NESTED(std::runtime_error("Cannot load certificate from '" + fileName + |
| "': malformed TLV or not in base64 format (" + e.what() + ")")); |
| } |
| } |
| |
| } // namespace nac |
| } // namespace ndn |
| |
| #endif // NAC_TOOLS_NDN_NAC_NDN_NAC_HPP |