blob: 000f61b15e637cd8f5543eb2c47cfe9cd0617c09 [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 Afanasyev2fa59392016-07-29 17:24:23 -07003 * Copyright (c) 2013-2016 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 {
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070030namespace security {
31
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070032/// @brief Callback to report a successful Interest validation.
33typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070034
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070035/// @brief Callback to report a failed Interest validation.
36typedef function<void(const shared_ptr<const Interest>&,
37 const std::string&)> OnInterestValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080038
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070039/// @brief Callback to report a successful Data validation.
40typedef function<void(const shared_ptr<const Data>&)> OnDataValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070041
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070042/// @brief Callback to report a failed Data validation.
43typedef function<void(const shared_ptr<const Data>&,
44 const std::string&)> OnDataValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080045
Yingdi Yud9006e72014-06-23 19:10:44 -070046/**
47 * @brief ValidationRequest contains information related to further validation.
48 *
49 * During a validation process, validator may not have retrieved the corresponding public
50 * key of the signature in a packet. ValidationRequest contains the interest for the
51 * certificate that carries the public key and also contains the context for the certificate
52 * including how to proceed when the public key is authenticated or not, the number of
53 * validation steps that have been performed, and how to handle interest timeout.
54 */
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070055class ValidationRequest
56{
Jeff Thompsonf309aa62013-10-31 17:03:54 -070057public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070058 ValidationRequest(const Interest& interest,
Yingdi Yud9006e72014-06-23 19:10:44 -070059 const OnDataValidated& onDataValidated,
60 const OnDataValidationFailed& onDataValidationFailed,
61 int nRetries, int nSteps)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070062 : m_interest(interest)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070063 , m_onDataValidated(onDataValidated)
Yingdi Yud9006e72014-06-23 19:10:44 -070064 , m_onDataValidationFailed(onDataValidationFailed)
65 , m_nRetries(nRetries)
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070066 , m_nSteps(nSteps)
67 {
68 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070069
Jeff Thompsonf309aa62013-10-31 17:03:54 -070070 virtual
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070071 ~ValidationRequest()
72 {
73 }
Jeff Thompsonf309aa62013-10-31 17:03:54 -070074
Yingdi Yud9006e72014-06-23 19:10:44 -070075 /// @brief the Interest for the requested data/certificate.
76 Interest m_interest;
77 /// @brief callback when the retrieved certificate is authenticated.
78 OnDataValidated m_onDataValidated;
79 /// @brief callback when the retrieved certificate cannot be authenticated.
80 OnDataValidationFailed m_onDataValidationFailed;
81 /// @brief the number of retries when the interest times out.
82 int m_nRetries;
83 /// @brief the number of validation steps that have been performed.
84 int m_nSteps;
Jeff Thompsonf309aa62013-10-31 17:03:54 -070085};
86
Alexander Afanasyev2fa59392016-07-29 17:24:23 -070087} // namespace security
88
89using security::ValidationRequest;
90using security::OnInterestValidated;
91using security::OnInterestValidationFailed;
92using security::OnDataValidated;
93using security::OnDataValidationFailed;
94
Yingdi Yu40587c02014-02-21 16:40:48 -080095} // namespace ndn
Jeff Thompsonf309aa62013-10-31 17:03:54 -070096
Yingdi Yu40587c02014-02-21 16:40:48 -080097#endif //NDN_SECURITY_VALIDATION_REQUEST_HPP