blob: d9aae80a38ea556841e9b4592d570a6acdb86a4a [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/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 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.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070020 *
21 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Jeff Thompsonf309aa62013-10-31 17:03:54 -070022 */
23
Yingdi Yu40587c02014-02-21 16:40:48 -080024#ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP
25#define NDN_SECURITY_VALIDATION_REQUEST_HPP
Jeff Thompsonf309aa62013-10-31 17:03:54 -070026
Yingdi Yu4f324632014-01-15 18:10:03 -080027#include "../interest.hpp"
Jeff Thompsonf309aa62013-10-31 17:03:54 -070028
29namespace ndn {
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,
59 int nRetries, int nSteps)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070060 : m_interest(interest)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070061 , m_onDataValidated(onDataValidated)
Yingdi Yud9006e72014-06-23 19:10:44 -070062 , m_onDataValidationFailed(onDataValidationFailed)
63 , m_nRetries(nRetries)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070064 , m_nSteps(nSteps)
65 {
66 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070067
Jeff Thompsonf309aa62013-10-31 17:03:54 -070068 virtual
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070069 ~ValidationRequest()
70 {
71 }
Jeff Thompsonf309aa62013-10-31 17:03:54 -070072
Yingdi Yud9006e72014-06-23 19:10:44 -070073 /// @brief the Interest for the requested data/certificate.
74 Interest m_interest;
75 /// @brief callback when the retrieved certificate is authenticated.
76 OnDataValidated m_onDataValidated;
77 /// @brief callback when the retrieved certificate cannot be authenticated.
78 OnDataValidationFailed m_onDataValidationFailed;
79 /// @brief the number of retries when the interest times out.
80 int m_nRetries;
81 /// @brief the number of validation steps that have been performed.
82 int m_nSteps;
Jeff Thompsonf309aa62013-10-31 17:03:54 -070083};
84
Yingdi Yu40587c02014-02-21 16:40:48 -080085} // namespace ndn
Jeff Thompsonf309aa62013-10-31 17:03:54 -070086
Yingdi Yu40587c02014-02-21 16:40:48 -080087#endif //NDN_SECURITY_VALIDATION_REQUEST_HPP