do some file move and rename
Change-Id: I034ea026c52c588966d2c66fcb3d3deea2e40102
diff --git a/src/identity-challenge/challenge-email.hpp b/src/identity-challenge/challenge-email.hpp
new file mode 100644
index 0000000..5cab3cb
--- /dev/null
+++ b/src/identity-challenge/challenge-email.hpp
@@ -0,0 +1,93 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2017-2019, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#ifndef NDNCERT_CHALLENGE_EMAIL_HPP
+#define NDNCERT_CHALLENGE_EMAIL_HPP
+
+#include "challenge-module.hpp"
+
+namespace ndn {
+namespace ndncert {
+
+/**
+ * @brief Provide Email based challenge
+ *
+ * For challenge design
+ * @sa https://github.com/named-data/ndncert/wiki/NDN-Certificate-Management-Protocol
+ * For deployment instructions:
+ * @sa https://github.com/named-data/ndncert/wiki/Deploy-Email-Challenge
+ *
+ * The main process of this challenge module is:
+ * 1. Requester provides its email address.
+ * 2. The challenge module will send a verification code to this email address.
+ * 3. Requester provides the verification code to challenge module.
+ *
+ * There are several challenge status in EMAIL challenge:
+ * NEED_CODE: When email address is provided and the verification code has been sent out.
+ * WRONG_CODE: Wrong code but still within secret lifetime and within max try times.
+ *
+ * Failure info when application fails:
+ * FAILURE_MAXRETRY: When run out retry times.
+ * FAILURE_INVALID_EMAIL: When the email is invalid.
+ * FAILURE_TIMEOUT: When the secret lifetime expires.
+ */
+class ChallengeEmail : public ChallengeModule
+{
+public:
+ ChallengeEmail(const std::string& scriptPath = "ndncert-send-email-challenge",
+ const size_t& maxAttemptTimes = 3,
+ const time::seconds secretLifetime = time::seconds(300));
+
+ // For CA
+ std::tuple<ErrorCode, std::string>
+ handleChallengeRequest(const Block& params, CaState& request) override;
+
+ // For Client
+ std::vector<std::tuple<std::string, std::string>>
+ getRequestedParameterList(Status status, const std::string& challengeStatus) override;
+
+ Block
+ genChallengeRequestTLV(Status status, const std::string& challengeStatus,
+ std::vector<std::tuple<std::string, std::string>>&& params) override;
+
+ // challenge status
+ static const std::string NEED_CODE;
+ static const std::string WRONG_CODE;
+ static const std::string INVALID_EMAIL;
+ // challenge parameters
+ static const std::string PARAMETER_KEY_EMAIL;
+ static const std::string PARAMETER_KEY_CODE;
+
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+ static bool
+ isValidEmailAddress(const std::string& emailAddress);
+
+ void
+ sendEmail(const std::string& emailAddress, const std::string& secret,
+ const CaState& request) const;
+
+private:
+ std::string m_sendEmailScript;
+};
+
+} // namespace ndncert
+} // namespace ndn
+
+#endif // NDNCERT_CHALLENGE_EMAIL_HPP