blob: 07f4b88806c9008229857ba0c022bfd5b4c40393 [file] [log] [blame]
Zhiyi Zhang0a89b722017-04-28 17:56:01 -07001/**
2 * Copyright (c) 2017, Regents of the University of California.
3 *
4 * This file is part of ndncert, a certificate management system based on NDN.
5 *
6 * ndncert is free software: you can redistribute it and/or modify it under the terms
7 * of the GNU General Public License as published by the Free Software Foundation, either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
13 *
14 * You should have received copies of the GNU General Public License along with
15 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * See AUTHORS.md for complete list of ndncert authors and contributors.
18 */
19
20#ifndef NDNCERT_CHALLENGE_CREDENTIAL_HPP
21#define NDNCERT_CHALLENGE_CREDENTIAL_HPP
22
23#include "../challenge-module.hpp"
24
25namespace ndn {
26namespace ndncert {
27
28/**
29 * @brief Provide Credential based challenge
30 *
31 * Credential here means the certificate issued by a trust anchor. Once the requester
32 * could proof his/her possession of an existing certificate from other certificate, th
33 * requester could finish the challenge.
34 *
35 * The main process of this challenge module is:
36 * 1. Requester provides a certificate signed by that trusted certificate as credential.
37 * 2. The challenge module will verify the signature of the credential.
38 *
39 * There are several challenge status in EMAIL challenge:
40 * FAILURE_INVALID_SIG: When the credential cannot be validated.
41 */
42class ChallengeCredential : public ChallengeModule
43{
44public:
45 ChallengeCredential(const std::string& configPath = "challenge-credential.conf");
46
47PUBLIC_WITH_TESTS_ELSE_PROTECTED:
48 JsonSection
49 processSelectInterest(const Interest& interest, CertificateRequest& request) override;
50
51 JsonSection
52 processValidateInterest(const Interest& interest, CertificateRequest& request) override;
53
54 std::list<std::string>
55 getSelectRequirements() override;
56
57 std::list<std::string>
58 getValidateRequirements(const std::string& status) override;
59
60 JsonSection
61 doGenSelectParamsJson(const std::string& status,
62 const std::list<std::string>& paramList) override;
63
64 JsonSection
65 doGenValidateParamsJson(const std::string& status,
66 const std::list<std::string>& paramList) override;
67
68PUBLIC_WITH_TESTS_ELSE_PRIVATE:
69 void
70 parseConfigFile();
71
72PUBLIC_WITH_TESTS_ELSE_PRIVATE:
73 static const std::string FAILURE_INVALID_CREDENTIAL;
74 static const std::string FAILURE_INVALID_FORMAT;
75 static const std::string JSON_CREDENTIAL;
76
77PUBLIC_WITH_TESTS_ELSE_PRIVATE:
78 std::list<security::v2::Certificate> m_trustAnchors;
79 std::string m_configFile;
80};
81
82} // namespace ndncert
83} // namespace ndn
84
85#endif // NDNCERT_CHALLENGE_CREDENTIAL_HPP