blob: a48e3654b3981891d96b0f81d6068de6abc871f5 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompsonf309aa62013-10-31 17:03:54 -07002/**
Zhiyi Zhang48becde2017-01-05 16:41:38 -08003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * 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.
Jeff Thompsonf309aa62013-10-31 17:03:54 -070020 */
21
Yingdi Yu40587c02014-02-21 16:40:48 -080022#ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP
23#define NDN_SECURITY_VALIDATION_REQUEST_HPP
Jeff Thompsonf309aa62013-10-31 17:03:54 -070024
Yingdi Yu4f324632014-01-15 18:10:03 -080025#include "../interest.hpp"
Jeff Thompsonf309aa62013-10-31 17:03:54 -070026
27namespace ndn {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070028namespace security {
29
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070030/// @brief Callback to report a successful Interest validation.
31typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070033/// @brief Callback to report a failed Interest validation.
34typedef function<void(const shared_ptr<const Interest>&,
35 const std::string&)> OnInterestValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080036
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070037/// @brief Callback to report a successful Data validation.
38typedef function<void(const shared_ptr<const Data>&)> OnDataValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070040/// @brief Callback to report a failed Data validation.
41typedef function<void(const shared_ptr<const Data>&,
42 const std::string&)> OnDataValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080043
Yingdi Yud9006e72014-06-23 19:10:44 -070044/**
45 * @brief ValidationRequest contains information related to further validation.
46 *
47 * During a validation process, validator may not have retrieved the corresponding public
48 * key of the signature in a packet. ValidationRequest contains the interest for the
49 * certificate that carries the public key and also contains the context for the certificate
50 * including how to proceed when the public key is authenticated or not, the number of
51 * validation steps that have been performed, and how to handle interest timeout.
52 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070053class ValidationRequest
54{
Jeff Thompsonf309aa62013-10-31 17:03:54 -070055public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070056 ValidationRequest(const Interest& interest,
Yingdi Yud9006e72014-06-23 19:10:44 -070057 const OnDataValidated& onDataValidated,
58 const OnDataValidationFailed& onDataValidationFailed,
Zhiyi Zhang48becde2017-01-05 16:41:38 -080059 int nRetries, int nSteps,
60 uint64_t requesterFaceId = 0)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070061 : m_interest(interest)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070062 , m_onDataValidated(onDataValidated)
Yingdi Yud9006e72014-06-23 19:10:44 -070063 , m_onDataValidationFailed(onDataValidationFailed)
64 , m_nRetries(nRetries)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070065 , m_nSteps(nSteps)
Zhiyi Zhang48becde2017-01-05 16:41:38 -080066 , m_requesterFaceId(requesterFaceId)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070067 {
68 }
Jeff Thompsonf309aa62013-10-31 17:03:54 -070069
Yingdi Yud9006e72014-06-23 19:10:44 -070070 /// @brief the Interest for the requested data/certificate.
71 Interest m_interest;
72 /// @brief callback when the retrieved certificate is authenticated.
73 OnDataValidated m_onDataValidated;
74 /// @brief callback when the retrieved certificate cannot be authenticated.
75 OnDataValidationFailed m_onDataValidationFailed;
76 /// @brief the number of retries when the interest times out.
77 int m_nRetries;
78 /// @brief the number of validation steps that have been performed.
79 int m_nSteps;
Zhiyi Zhang48becde2017-01-05 16:41:38 -080080 /// @brief the incoming face id of the origin packet.
81 uint64_t m_requesterFaceId;
Jeff Thompsonf309aa62013-10-31 17:03:54 -070082};
83
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070084} // namespace security
85
86using security::ValidationRequest;
87using security::OnInterestValidated;
88using security::OnInterestValidationFailed;
89using security::OnDataValidated;
90using security::OnDataValidationFailed;
91
Yingdi Yu40587c02014-02-21 16:40:48 -080092} // namespace ndn
Jeff Thompsonf309aa62013-10-31 17:03:54 -070093
Yingdi Yu40587c02014-02-21 16:40:48 -080094#endif //NDN_SECURITY_VALIDATION_REQUEST_HPP