Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library 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 Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 20 | */ |
| 21 | |
| 22 | #ifndef NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP |
| 23 | #define NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP |
| 24 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 25 | #include "../security/signing-info.hpp" |
| 26 | |
| 27 | #define NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 30 | |
| 31 | class IdentityCertificate; |
| 32 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 33 | namespace nfd { |
| 34 | |
| 35 | /** \ingroup management |
| 36 | * \brief contains options for ControlCommand execution |
| 37 | * \note This type is intentionally copyable |
| 38 | */ |
| 39 | class CommandOptions |
| 40 | { |
| 41 | public: |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 42 | /** \brief constructs CommandOptions |
| 43 | * \post getTimeout() == DEFAULT_TIMEOUT |
| 44 | * \post getPrefix() == DEFAULT_PREFIX |
| 45 | * \post getSigningInfo().getSignerType() == SIGNER_TYPE_NULL |
| 46 | */ |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 47 | CommandOptions(); |
| 48 | |
| 49 | /** \return command timeout |
| 50 | */ |
| 51 | const time::milliseconds& |
| 52 | getTimeout() const |
| 53 | { |
| 54 | return m_timeout; |
| 55 | } |
| 56 | |
| 57 | /** \brief sets command timeout |
| 58 | * \param timeout the new command timeout, must be positive |
| 59 | * \throw std::out_of_range if timeout is non-positive |
| 60 | * \return self |
| 61 | */ |
| 62 | CommandOptions& |
| 63 | setTimeout(const time::milliseconds& timeout); |
| 64 | |
| 65 | /** \return command prefix |
| 66 | */ |
| 67 | const Name& |
| 68 | getPrefix() const |
| 69 | { |
| 70 | return m_prefix; |
| 71 | } |
| 72 | |
| 73 | /** \brief sets command prefix |
| 74 | * \return self |
| 75 | */ |
| 76 | CommandOptions& |
| 77 | setPrefix(const Name& prefix); |
| 78 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 79 | /** \return signing parameters |
| 80 | */ |
| 81 | const security::SigningInfo& |
| 82 | getSigningInfo() const |
| 83 | { |
| 84 | return m_signingInfo; |
| 85 | } |
| 86 | |
| 87 | /** \brief sets signing parameters |
| 88 | * \return self |
| 89 | */ |
| 90 | CommandOptions& |
| 91 | setSigningInfo(const security::SigningInfo& signingInfo); |
| 92 | |
| 93 | #ifdef NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 94 | public: // signing parameters |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 95 | /** \deprecated use getSigningInfo and setSigningInfo |
| 96 | * \brief indicates the selection of signing parameters |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 97 | */ |
| 98 | enum SigningParamsKind { |
| 99 | /** \brief picks the default signing identity and certificate |
| 100 | */ |
| 101 | SIGNING_PARAMS_DEFAULT, |
| 102 | /** \brief picks the default certificate of a specific identity Name |
| 103 | */ |
| 104 | SIGNING_PARAMS_IDENTITY, |
| 105 | /** \brief picks a specific identity certificate |
| 106 | */ |
| 107 | SIGNING_PARAMS_CERTIFICATE |
| 108 | }; |
| 109 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 110 | /** \deprecated use getSigningInfo and setSigningInfo |
| 111 | * \return selection of signing parameters |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 112 | */ |
| 113 | SigningParamsKind |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 114 | getSigningParamsKind() const; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 115 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 116 | /** \deprecated use getSigningInfo and setSigningInfo |
| 117 | * \return identity Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 118 | * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 119 | */ |
| 120 | const Name& |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 121 | getSigningIdentity() const; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 122 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 123 | /** \deprecated use getSigningInfo and setSigningInfo |
| 124 | * \return certificate Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 125 | * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
| 126 | */ |
| 127 | const Name& |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 128 | getSigningCertificate() const; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 129 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 130 | /** \deprecated use getSigningInfo and setSigningInfo |
| 131 | * \brief chooses to use default identity and certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 132 | * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT |
| 133 | * \return self |
| 134 | */ |
| 135 | CommandOptions& |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 136 | setSigningDefault(); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 137 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 138 | /** \deprecated use getSigningInfo and setSigningInfo |
| 139 | * \brief chooses to use a specific identity and its default certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 140 | * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 141 | * \post getIdentityName() == identityName |
| 142 | * \return self |
| 143 | */ |
| 144 | CommandOptions& |
| 145 | setSigningIdentity(const Name& identityName); |
| 146 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 147 | /** \deprecated use getSigningInfo and setSigningInfo |
| 148 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 149 | * \param certificateName identity certificate Name |
| 150 | * \throw std::invalid_argument if certificateName is invalid |
| 151 | * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 152 | * \post getSigningCertificate() == certificateName |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 153 | * \return self |
| 154 | */ |
| 155 | CommandOptions& |
| 156 | setSigningCertificate(const Name& certificateName); |
| 157 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 158 | /** \deprecated use getSigningInfo and setSigningInfo |
| 159 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 160 | * \details This is equivalent to .setIdentityCertificate(certificate.getName()) |
| 161 | */ |
| 162 | CommandOptions& |
| 163 | setSigningCertificate(const IdentityCertificate& certificate); |
| 164 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 165 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
| 166 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 167 | public: |
| 168 | /** \brief gives the default command timeout: 10000ms |
| 169 | */ |
| 170 | static const time::milliseconds DEFAULT_TIMEOUT; |
| 171 | |
| 172 | /** \brief gives the default command prefix: ndn:/localhost/nfd |
| 173 | */ |
| 174 | static const Name DEFAULT_PREFIX; |
| 175 | |
| 176 | private: |
| 177 | time::milliseconds m_timeout; |
| 178 | Name m_prefix; |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame^] | 179 | security::SigningInfo m_signingInfo; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | } // namespace nfd |
| 183 | } // namespace ndn |
| 184 | |
| 185 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP |