Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 2 | /** |
Zhiyi Zhang | 48becde | 2017-01-05 16:41:38 -0800 | [diff] [blame^] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 22 | #ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP |
| 23 | #define NDN_SECURITY_VALIDATION_REQUEST_HPP |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 24 | |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 25 | #include "../interest.hpp" |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 26 | |
| 27 | namespace ndn { |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 28 | namespace security { |
| 29 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 30 | /// @brief Callback to report a successful Interest validation. |
| 31 | typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 32 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 33 | /// @brief Callback to report a failed Interest validation. |
| 34 | typedef function<void(const shared_ptr<const Interest>&, |
| 35 | const std::string&)> OnInterestValidationFailed; |
Yingdi Yu | 6ac9798 | 2014-01-30 14:49:21 -0800 | [diff] [blame] | 36 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 37 | /// @brief Callback to report a successful Data validation. |
| 38 | typedef function<void(const shared_ptr<const Data>&)> OnDataValidated; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 39 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 40 | /// @brief Callback to report a failed Data validation. |
| 41 | typedef function<void(const shared_ptr<const Data>&, |
| 42 | const std::string&)> OnDataValidationFailed; |
Yingdi Yu | 6ac9798 | 2014-01-30 14:49:21 -0800 | [diff] [blame] | 43 | |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 44 | /** |
| 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 Afanasyev | 2a7f720 | 2014-04-23 14:25:29 -0700 | [diff] [blame] | 53 | class ValidationRequest |
| 54 | { |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 55 | public: |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 56 | ValidationRequest(const Interest& interest, |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 57 | const OnDataValidated& onDataValidated, |
| 58 | const OnDataValidationFailed& onDataValidationFailed, |
Zhiyi Zhang | 48becde | 2017-01-05 16:41:38 -0800 | [diff] [blame^] | 59 | int nRetries, int nSteps, |
| 60 | uint64_t requesterFaceId = 0) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 61 | : m_interest(interest) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 62 | , m_onDataValidated(onDataValidated) |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 63 | , m_onDataValidationFailed(onDataValidationFailed) |
| 64 | , m_nRetries(nRetries) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 65 | , m_nSteps(nSteps) |
Zhiyi Zhang | 48becde | 2017-01-05 16:41:38 -0800 | [diff] [blame^] | 66 | , m_requesterFaceId(requesterFaceId) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 67 | { |
| 68 | } |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 69 | |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 70 | /// @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 Zhang | 48becde | 2017-01-05 16:41:38 -0800 | [diff] [blame^] | 80 | /// @brief the incoming face id of the origin packet. |
| 81 | uint64_t m_requesterFaceId; |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 84 | } // namespace security |
| 85 | |
| 86 | using security::ValidationRequest; |
| 87 | using security::OnInterestValidated; |
| 88 | using security::OnInterestValidationFailed; |
| 89 | using security::OnDataValidated; |
| 90 | using security::OnDataValidationFailed; |
| 91 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 92 | } // namespace ndn |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 93 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 94 | #endif //NDN_SECURITY_VALIDATION_REQUEST_HPP |