blob: 7d43c1dbbd428381d7c0b3fc7caf3a99e503c246 [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 */
113 SigningParamsKind
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700114 getSigningParamsKind() const;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700115
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700116 /** \deprecated use getSigningInfo and setSigningInfo
117 * \return identity Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700118 * \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
119 */
120 const Name&
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700121 getSigningIdentity() const;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700122
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700123 /** \deprecated use getSigningInfo and setSigningInfo
124 * \return certificate Name
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700125 * \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
126 */
127 const Name&
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700128 getSigningCertificate() const;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700129
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700130 /** \deprecated use getSigningInfo and setSigningInfo
131 * \brief chooses to use default identity and certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700132 * \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT
133 * \return self
134 */
135 CommandOptions&
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700136 setSigningDefault();
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700137
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700138 /** \deprecated use getSigningInfo and setSigningInfo
139 * \brief chooses to use a specific identity and its default certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700140 * \post getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
141 * \post getIdentityName() == identityName
142 * \return self
143 */
144 CommandOptions&
145 setSigningIdentity(const Name& identityName);
146
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700147 /** \deprecated use getSigningInfo and setSigningInfo
148 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700149 * \param certificateName identity certificate Name
150 * \throw std::invalid_argument if certificateName is invalid
151 * \post getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700152 * \post getSigningCertificate() == certificateName
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700153 * \return self
154 */
155 CommandOptions&
156 setSigningCertificate(const Name& certificateName);
157
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700158 /** \deprecated use getSigningInfo and setSigningInfo
159 * \brief chooses to use a specific identity certificate
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700160 * \details This is equivalent to .setIdentityCertificate(certificate.getName())
161 */
162 CommandOptions&
163 setSigningCertificate(const IdentityCertificate& certificate);
164
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700165#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
166
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700167public:
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
176private:
177 time::milliseconds m_timeout;
178 Name m_prefix;
Junxiao Shic6acc7a2015-06-23 10:03:56 -0700179 security::SigningInfo m_signingInfo;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -0700180};
181
182} // namespace nfd
183} // namespace ndn
184
185#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_HPP