blob: b88356f0307e65e9e2b80d325f0ecb5884556a66 [file] [log] [blame]
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07001/* -*- 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 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
31class IdentityCertificate;
32
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070033namespace nfd {
34
35/** \ingroup management
36 * \brief contains options for ControlCommand execution
37 * \note This type is intentionally copyable
38 */
39class CommandOptions
40{
41public:
Junxiao Shic6acc7a2015-06-23 10:03:56 -070042 /** \brief constructs CommandOptions
43 * \post getTimeout() == DEFAULT_TIMEOUT
44 * \post getPrefix() == DEFAULT_PREFIX
45 * \post getSigningInfo().getSignerType() == SIGNER_TYPE_NULL
46 */
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070047 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 Shic6acc7a2015-06-23 10:03:56 -070079 /** \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 Shi0eba1aa2014-10-25 09:54:08 -070094public: // signing parameters
Junxiao Shic6acc7a2015-06-23 10:03:56 -070095 /** \deprecated use getSigningInfo and setSigningInfo
96 * \brief indicates the selection of signing parameters
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070097 */
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 Shic6acc7a2015-06-23 10:03:56 -0700110 /** \deprecated use getSigningInfo and setSigningInfo
111 * \return selection of signing parameters
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700112 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700113 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700114 SigningParamsKind
Junxiao Shi35020ca2015-07-01 16:46:51 -0700115 getSigningParamsKind() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700116
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700117 /** \deprecated use getSigningInfo and setSigningInfo
118 * \return identity Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700119 * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
120 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700121 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700122 const Name&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700123 getSigningIdentity() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700124
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700125 /** \deprecated use getSigningInfo and setSigningInfo
126 * \return certificate Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700127 * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
128 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700129 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700130 const Name&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700131 getSigningCertificate() const);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700132
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700133 /** \deprecated use getSigningInfo and setSigningInfo
134 * \brief chooses to use default identity and certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700135 * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT
136 * \return self
137 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700138 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700139 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700140 setSigningDefault());
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700141
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700142 /** \deprecated use getSigningInfo and setSigningInfo
143 * \brief chooses to use a specific identity and its default certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700144 * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
145 * \post getIdentityName() == identityName
146 * \return self
147 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700148 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700149 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700150 setSigningIdentity(const Name& identityName));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700151
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700152 /** \deprecated use getSigningInfo and setSigningInfo
153 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700154 * \param certificateName identity certificate Name
155 * \throw std::invalid_argument if certificateName is invalid
156 * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700157 * \post getSigningCertificate() == certificateName
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700158 * \return self
159 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700160 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700161 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700162 setSigningCertificate(const Name& certificateName));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700163
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700164 /** \deprecated use getSigningInfo and setSigningInfo
165 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700166 * \details This is equivalent to .setIdentityCertificate(certificate.getName())
167 */
Junxiao Shi35020ca2015-07-01 16:46:51 -0700168 DEPRECATED(
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700169 CommandOptions&
Junxiao Shi35020ca2015-07-01 16:46:51 -0700170 setSigningCertificate(const IdentityCertificate& certificate));
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700171
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700172#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
173
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700174public:
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
183private:
184 time::milliseconds m_timeout;
185 Name m_prefix;
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700186 security::SigningInfo m_signingInfo;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700187};
188
189} // namespace nfd
190} // namespace ndn
191
192#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP