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 | /** |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2013-2016 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. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 20 | * |
| 21 | * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/> |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 22 | */ |
| 23 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 24 | #ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP |
| 25 | #define NDN_SECURITY_VALIDATION_REQUEST_HPP |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 26 | |
Yingdi Yu | 4f32463 | 2014-01-15 18:10:03 -0800 | [diff] [blame] | 27 | #include "../interest.hpp" |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 28 | |
| 29 | namespace ndn { |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame^] | 30 | namespace security { |
| 31 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 32 | /// @brief Callback to report a successful Interest validation. |
| 33 | typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 34 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 35 | /// @brief Callback to report a failed Interest validation. |
| 36 | typedef function<void(const shared_ptr<const Interest>&, |
| 37 | const std::string&)> OnInterestValidationFailed; |
Yingdi Yu | 6ac9798 | 2014-01-30 14:49:21 -0800 | [diff] [blame] | 38 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 39 | /// @brief Callback to report a successful Data validation. |
| 40 | typedef function<void(const shared_ptr<const Data>&)> OnDataValidated; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 41 | |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 42 | /// @brief Callback to report a failed Data validation. |
| 43 | typedef function<void(const shared_ptr<const Data>&, |
| 44 | const std::string&)> OnDataValidationFailed; |
Yingdi Yu | 6ac9798 | 2014-01-30 14:49:21 -0800 | [diff] [blame] | 45 | |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 46 | /** |
| 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 Afanasyev | 2a7f720 | 2014-04-23 14:25:29 -0700 | [diff] [blame] | 55 | class ValidationRequest |
| 56 | { |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 57 | public: |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 58 | ValidationRequest(const Interest& interest, |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 59 | const OnDataValidated& onDataValidated, |
| 60 | const OnDataValidationFailed& onDataValidationFailed, |
| 61 | int nRetries, int nSteps) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 62 | : m_interest(interest) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 63 | , m_onDataValidated(onDataValidated) |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 64 | , m_onDataValidationFailed(onDataValidationFailed) |
| 65 | , m_nRetries(nRetries) |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 66 | , m_nSteps(nSteps) |
| 67 | { |
| 68 | } |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 69 | |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 70 | virtual |
Yingdi Yu | 4b8c6a2 | 2014-04-15 23:00:54 -0700 | [diff] [blame] | 71 | ~ValidationRequest() |
| 72 | { |
| 73 | } |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 74 | |
Yingdi Yu | d9006e7 | 2014-06-23 19:10:44 -0700 | [diff] [blame] | 75 | /// @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 Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame^] | 87 | } // namespace security |
| 88 | |
| 89 | using security::ValidationRequest; |
| 90 | using security::OnInterestValidated; |
| 91 | using security::OnInterestValidationFailed; |
| 92 | using security::OnDataValidated; |
| 93 | using security::OnDataValidationFailed; |
| 94 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 95 | } // namespace ndn |
Jeff Thompson | f309aa6 | 2013-10-31 17:03:54 -0700 | [diff] [blame] | 96 | |
Yingdi Yu | 40587c0 | 2014-02-21 16:40:48 -0800 | [diff] [blame] | 97 | #endif //NDN_SECURITY_VALIDATION_REQUEST_HPP |