Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 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 | |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 31 | namespace security { |
| 32 | namespace v1 { |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 33 | class IdentityCertificate; |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 34 | } // namespace v1 |
| 35 | } // namespace security |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 36 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 37 | namespace nfd { |
| 38 | |
| 39 | /** \ingroup management |
| 40 | * \brief contains options for ControlCommand execution |
| 41 | * \note This type is intentionally copyable |
| 42 | */ |
| 43 | class CommandOptions |
| 44 | { |
| 45 | public: |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 46 | /** \brief constructs CommandOptions |
| 47 | * \post getTimeout() == DEFAULT_TIMEOUT |
| 48 | * \post getPrefix() == DEFAULT_PREFIX |
| 49 | * \post getSigningInfo().getSignerType() == SIGNER_TYPE_NULL |
| 50 | */ |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 51 | CommandOptions(); |
| 52 | |
| 53 | /** \return command timeout |
| 54 | */ |
| 55 | const time::milliseconds& |
| 56 | getTimeout() const |
| 57 | { |
| 58 | return m_timeout; |
| 59 | } |
| 60 | |
| 61 | /** \brief sets command timeout |
| 62 | * \param timeout the new command timeout, must be positive |
| 63 | * \throw std::out_of_range if timeout is non-positive |
| 64 | * \return self |
| 65 | */ |
| 66 | CommandOptions& |
| 67 | setTimeout(const time::milliseconds& timeout); |
| 68 | |
| 69 | /** \return command prefix |
| 70 | */ |
| 71 | const Name& |
| 72 | getPrefix() const |
| 73 | { |
| 74 | return m_prefix; |
| 75 | } |
| 76 | |
| 77 | /** \brief sets command prefix |
| 78 | * \return self |
| 79 | */ |
| 80 | CommandOptions& |
| 81 | setPrefix(const Name& prefix); |
| 82 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 83 | /** \return signing parameters |
| 84 | */ |
| 85 | const security::SigningInfo& |
| 86 | getSigningInfo() const |
| 87 | { |
| 88 | return m_signingInfo; |
| 89 | } |
| 90 | |
| 91 | /** \brief sets signing parameters |
| 92 | * \return self |
| 93 | */ |
| 94 | CommandOptions& |
| 95 | setSigningInfo(const security::SigningInfo& signingInfo); |
| 96 | |
| 97 | #ifdef NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 98 | public: // signing parameters |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 99 | /** \deprecated use getSigningInfo and setSigningInfo |
| 100 | * \brief indicates the selection of signing parameters |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 101 | */ |
| 102 | enum SigningParamsKind { |
| 103 | /** \brief picks the default signing identity and certificate |
| 104 | */ |
| 105 | SIGNING_PARAMS_DEFAULT, |
| 106 | /** \brief picks the default certificate of a specific identity Name |
| 107 | */ |
| 108 | SIGNING_PARAMS_IDENTITY, |
| 109 | /** \brief picks a specific identity certificate |
| 110 | */ |
| 111 | SIGNING_PARAMS_CERTIFICATE |
| 112 | }; |
| 113 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 114 | /** \deprecated use getSigningInfo and setSigningInfo |
| 115 | * \return selection of signing parameters |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 116 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 117 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 118 | SigningParamsKind |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 119 | getSigningParamsKind() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 120 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 121 | /** \deprecated use getSigningInfo and setSigningInfo |
| 122 | * \return identity Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 123 | * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 124 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 125 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 126 | const Name& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 127 | getSigningIdentity() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 128 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 129 | /** \deprecated use getSigningInfo and setSigningInfo |
| 130 | * \return certificate Name |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 131 | * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
| 132 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 133 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 134 | const Name& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 135 | getSigningCertificate() const); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 136 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 137 | /** \deprecated use getSigningInfo and setSigningInfo |
| 138 | * \brief chooses to use default identity and certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 139 | * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT |
| 140 | * \return self |
| 141 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 142 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 143 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 144 | setSigningDefault()); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 145 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 146 | /** \deprecated use getSigningInfo and setSigningInfo |
| 147 | * \brief chooses to use a specific identity and its default certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 148 | * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY |
| 149 | * \post getIdentityName() == identityName |
| 150 | * \return self |
| 151 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 152 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 153 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 154 | setSigningIdentity(const Name& identityName)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 155 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 156 | /** \deprecated use getSigningInfo and setSigningInfo |
| 157 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 158 | * \param certificateName identity certificate Name |
| 159 | * \throw std::invalid_argument if certificateName is invalid |
| 160 | * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 161 | * \post getSigningCertificate() == certificateName |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 162 | * \return self |
| 163 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 164 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 165 | CommandOptions& |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 166 | setSigningCertificate(const Name& certificateName)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 167 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 168 | /** \deprecated use getSigningInfo and setSigningInfo |
| 169 | * \brief chooses to use a specific identity certificate |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 170 | * \details This is equivalent to .setIdentityCertificate(certificate.getName()) |
| 171 | */ |
Junxiao Shi | 35020ca | 2015-07-01 16:46:51 -0700 | [diff] [blame] | 172 | DEPRECATED( |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 173 | CommandOptions& |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 174 | setSigningCertificate(const security::v1::IdentityCertificate& certificate)); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 175 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 176 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS |
| 177 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 178 | public: |
| 179 | /** \brief gives the default command timeout: 10000ms |
| 180 | */ |
| 181 | static const time::milliseconds DEFAULT_TIMEOUT; |
| 182 | |
| 183 | /** \brief gives the default command prefix: ndn:/localhost/nfd |
| 184 | */ |
| 185 | static const Name DEFAULT_PREFIX; |
| 186 | |
| 187 | private: |
| 188 | time::milliseconds m_timeout; |
| 189 | Name m_prefix; |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 190 | security::SigningInfo m_signingInfo; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | } // namespace nfd |
| 194 | } // namespace ndn |
| 195 | |
| 196 | #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP |