blob: 4ca0a6b3ba1567c7180bd59312965a8c050d0188 [file] [log] [blame]
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev2fa59392016-07-29 17:24:23 -07003 * Copyright (c) 2013-2016 Regents of the University of California.
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07004 *
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 Shic6acc7a2015-06-23 10:03:56 -070025#include "../security/signing-info.hpp"
26
27#define NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070028
29namespace ndn {
Junxiao Shic6acc7a2015-06-23 10:03:56 -070030
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070031namespace security {
32namespace v1 {
Junxiao Shic6acc7a2015-06-23 10:03:56 -070033class IdentityCertificate;
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070034} // namespace v1
35} // namespace security
Junxiao Shic6acc7a2015-06-23 10:03:56 -070036
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070037namespace nfd {
38
39/** \ingroup management
40 * \brief contains options for ControlCommand execution
41 * \note This type is intentionally copyable
42 */
43class CommandOptions
44{
45public:
Junxiao Shic6acc7a2015-06-23 10:03:56 -070046 /** \brief constructs CommandOptions
47 * \post getTimeout() == DEFAULT_TIMEOUT
48 * \post getPrefix() == DEFAULT_PREFIX
49 * \post getSigningInfo().getSignerType() == SIGNER_TYPE_NULL
50 */
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070051 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 Shic6acc7a2015-06-23 10:03:56 -070083 /** \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 Shi0eba1aa2014-10-25 09:54:08 -070098public: // signing parameters
Junxiao Shic6acc7a2015-06-23 10:03:56 -070099 /** \deprecated use getSigningInfo and setSigningInfo
100 * \brief indicates the selection of signing parameters
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700101 */
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 Shic6acc7a2015-06-23 10:03:56 -0700114 /** \deprecated use getSigningInfo and setSigningInfo
115 * \return selection of signing parameters
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700116 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700117 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700118 SigningParamsKind
Junxiao Shi35020ca2015-07-01 16:46:51 -0700119 getSigningParamsKind() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700120
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700121 /** \deprecated use getSigningInfo and setSigningInfo
122 * \return identity Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700123 * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
124 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700125 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700126 const Name&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700127 getSigningIdentity() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700128
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700129 /** \deprecated use getSigningInfo and setSigningInfo
130 * \return certificate Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700131 * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
132 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700133 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700134 const Name&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700135 getSigningCertificate() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700136
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700137 /** \deprecated use getSigningInfo and setSigningInfo
138 * \brief chooses to use default identity and certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700139 * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT
140 * \return self
141 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700142 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700143 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700144 setSigningDefault());
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700145
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700146 /** \deprecated use getSigningInfo and setSigningInfo
147 * \brief chooses to use a specific identity and its default certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700148 * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
149 * \post getIdentityName() == identityName
150 * \return self
151 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700152 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700153 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700154 setSigningIdentity(const Name& identityName));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700155
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700156 /** \deprecated use getSigningInfo and setSigningInfo
157 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700158 * \param certificateName identity certificate Name
159 * \throw std::invalid_argument if certificateName is invalid
160 * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700161 * \post getSigningCertificate() == certificateName
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700162 * \return self
163 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700164 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700165 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700166 setSigningCertificate(const Name& certificateName));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700167
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700168 /** \deprecated use getSigningInfo and setSigningInfo
169 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700170 * \details This is equivalent to .setIdentityCertificate(certificate.getName())
171 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700172 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700173 CommandOptions&
Alexander Afanasyev2fa59392016-07-29 17:24:23 -0700174 setSigningCertificate(const security::v1::IdentityCertificate& certificate));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700175
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700176#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
177
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700178public:
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
187private:
188 time::milliseconds m_timeout;
189 Name m_prefix;
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700190 security::SigningInfo m_signingInfo;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700191};
192
193} // namespace nfd
194} // namespace ndn
195
196#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP