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 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 113 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 114 | SigningParamsKind |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 115 | getSigningParamsKind() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 116 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 117 | /** \deprecated use getSigningInfo and setSigningInfo |
| 118 | * \return identity Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 119 | * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 120 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 121 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 122 | const Name& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 123 | getSigningIdentity() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 124 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 125 | /** \deprecated use getSigningInfo and setSigningInfo |
| 126 | * \return certificate Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 127 | * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
| 128 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 129 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 130 | const Name& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 131 | getSigningCertificate() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 132 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 133 | /** \deprecated use getSigningInfo and setSigningInfo |
| 134 | * \brief chooses to use default identity and certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 135 | * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT |
| 136 | * \return self |
| 137 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 138 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 139 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 140 | setSigningDefault()); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 141 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 142 | /** \deprecated use getSigningInfo and setSigningInfo |
| 143 | * \brief chooses to use a specific identity and its default certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 144 | * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 145 | * \post getIdentityName() == identityName |
| 146 | * \return self |
| 147 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 148 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 149 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 150 | setSigningIdentity(const Name& identityName)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 151 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 152 | /** \deprecated use getSigningInfo and setSigningInfo |
| 153 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 154 | * \param certificateName identity certificate Name |
| 155 | * \throw std::invalid_argument if certificateName is invalid |
| 156 | * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 157 | * \post getSigningCertificate() == certificateName |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 158 | * \return self |
| 159 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 160 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 161 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 162 | setSigningCertificate(const Name& certificateName)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 163 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 164 | /** \deprecated use getSigningInfo and setSigningInfo |
| 165 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 166 | * \details This is equivalent to .setIdentityCertificate(certificate.getName()) |
| 167 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 168 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 169 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 170 | setSigningCertificate(const IdentityCertificate& certificate)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 171 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 172 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
| 173 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 174 | public: |
| 175 | /** \brief gives the default command timeout: 10000ms |
| 176 | */ |
| 177 | static const time::milliseconds DEFAULT_TIMEOUT; |
| 178 | |
| 179 | /** \brief gives the default command prefix: ndn:/localhost/nfd |
| 180 | */ |
| 181 | static const Name DEFAULT_PREFIX; |
| 182 | |
| 183 | private: |
| 184 | time::milliseconds m_timeout; |
| 185 | Name m_prefix; |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 186 | security::SigningInfo m_signingInfo; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 187 | }; |
| 188 | |
| 189 | } // namespace nfd |
| 190 | } // namespace ndn |
| 191 | |
| 192 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP |