rename identity challenge dir to challenge
Change-Id: Ieb89704404dae2086bd83987624670432bb69663
diff --git a/src/ca-module.cpp b/src/ca-module.cpp
index f4e03c0..ee55132 100644
--- a/src/ca-module.cpp
+++ b/src/ca-module.cpp
@@ -20,7 +20,7 @@
#include "ca-module.hpp"
#include "detail/crypto-helpers.hpp"
-#include "identity-challenge/challenge-module.hpp"
+#include "challenge/challenge-module.hpp"
#include "name-assignment/assignment-func.hpp"
#include "detail/challenge-encoder.hpp"
#include "detail/error-encoder.hpp"
@@ -306,7 +306,7 @@
}
RequestId id;
std::memcpy(id.data(), requestIdData, id.size());
- RequestState requestState( m_config.m_caProfile.m_caPrefix, id, requestType,
+ RequestState requestState(m_config.m_caProfile.m_caPrefix, id, requestType,
Status::BEFORE_CHALLENGE, *clientCert, std::move(aesKey));
try {
m_storage->addRequest(requestState);
diff --git a/src/identity-challenge/challenge-credential.cpp b/src/challenge/challenge-credential.cpp
similarity index 100%
rename from src/identity-challenge/challenge-credential.cpp
rename to src/challenge/challenge-credential.cpp
diff --git a/src/identity-challenge/challenge-credential.hpp b/src/challenge/challenge-credential.hpp
similarity index 100%
rename from src/identity-challenge/challenge-credential.hpp
rename to src/challenge/challenge-credential.hpp
diff --git a/src/identity-challenge/challenge-email.cpp b/src/challenge/challenge-email.cpp
similarity index 100%
rename from src/identity-challenge/challenge-email.cpp
rename to src/challenge/challenge-email.cpp
diff --git a/src/identity-challenge/challenge-email.hpp b/src/challenge/challenge-email.hpp
similarity index 100%
rename from src/identity-challenge/challenge-email.hpp
rename to src/challenge/challenge-email.hpp
diff --git a/src/identity-challenge/challenge-module.cpp b/src/challenge/challenge-module.cpp
similarity index 98%
rename from src/identity-challenge/challenge-module.cpp
rename to src/challenge/challenge-module.cpp
index e58b0aa..8de88b6 100644
--- a/src/identity-challenge/challenge-module.cpp
+++ b/src/challenge/challenge-module.cpp
@@ -18,7 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
-#include "identity-challenge/challenge-module.hpp"
+#include "challenge/challenge-module.hpp"
#include <ndn-cxx/util/random.hpp>
namespace ndn {
diff --git a/src/identity-challenge/challenge-module.hpp b/src/challenge/challenge-module.hpp
similarity index 100%
rename from src/identity-challenge/challenge-module.hpp
rename to src/challenge/challenge-module.hpp
diff --git a/src/identity-challenge/challenge-pin.cpp b/src/challenge/challenge-pin.cpp
similarity index 100%
rename from src/identity-challenge/challenge-pin.cpp
rename to src/challenge/challenge-pin.cpp
diff --git a/src/identity-challenge/challenge-pin.hpp b/src/challenge/challenge-pin.hpp
similarity index 100%
rename from src/identity-challenge/challenge-pin.hpp
rename to src/challenge/challenge-pin.hpp
diff --git a/src/detail/ca-profile.cpp b/src/detail/ca-profile.cpp
index bd826e9..5216ae0 100644
--- a/src/detail/ca-profile.cpp
+++ b/src/detail/ca-profile.cpp
@@ -19,7 +19,7 @@
*/
#include "detail/ca-profile.hpp"
-#include "identity-challenge/challenge-module.hpp"
+#include "challenge/challenge-module.hpp"
#include <ndn-cxx/util/io.hpp>
#include <boost/filesystem.hpp>
diff --git a/src/detail/ca-profile.hpp b/src/detail/ca-profile.hpp
index c9599f9..3fe0180 100644
--- a/src/detail/ca-profile.hpp
+++ b/src/detail/ca-profile.hpp
@@ -57,39 +57,37 @@
public:
/**
- * CA Name prefix (without /CA suffix).
+ * @brief CA Name prefix (without /CA suffix).
*/
Name m_caPrefix;
/**
- * CA Information.
- * Default: "".
+ * @brief CA Information.
*/
std::string m_caInfo;
/**
- * A list of parameter-keys for PROBE.
- * Default: empty list.
+ * @brief A list of parameter-keys for PROBE.
*/
std::list<std::string> m_probeParameterKeys;
/**
- * Maximum allowed validity period of the certificate being requested.
+ * @brief Maximum allowed validity period of the certificate being requested.
+ *
* The value is in the unit of second.
* Default: one day (86400 seconds).
*/
time::seconds m_maxValidityPeriod;
/**
- * Maximum allowed suffix length of requested name.
+ * @brief Maximum allowed suffix length of requested name.
+ *
* E.g., When its value is 2, at most 2 name components can be assigned after m_caPrefix.
* Default: none.
*/
optional<size_t> m_maxSuffixLength = nullopt;
/**
- * A list of supported challenges. Only CA side will have m_supportedChallenges.
- * Default: empty list.
+ * @brief A list of supported challenges. Only CA side will have m_supportedChallenges.
*/
std::list<std::string> m_supportedChallenges;
/**
- * CA's certificate. Only Client side will have m_cert.
- * Default: nullptr.
+ * @brief CA's certificate. Only Client side will have m_cert.
*/
std::shared_ptr<security::Certificate> m_cert;
};
diff --git a/src/detail/ca-request-state.cpp b/src/detail/ca-request-state.cpp
index 923f9be..adb453f 100644
--- a/src/detail/ca-request-state.cpp
+++ b/src/detail/ca-request-state.cpp
@@ -38,10 +38,6 @@
return "Success";
case Status::FAILURE:
return "Failure";
- case Status::NOT_STARTED:
- return "Not started";
- case Status::ENDED:
- return "Ended";
default:
return "Unrecognized status";
}
diff --git a/src/detail/ca-request-state.hpp b/src/detail/ca-request-state.hpp
index 27d19fa..160760e 100644
--- a/src/detail/ca-request-state.hpp
+++ b/src/detail/ca-request-state.hpp
@@ -34,9 +34,7 @@
CHALLENGE = 1,
PENDING = 2,
SUCCESS = 3,
- FAILURE = 4,
- NOT_STARTED = 5,
- ENDED = 6
+ FAILURE = 4
};
/**
@@ -121,7 +119,7 @@
/**
* @brief The status of the request.
*/
- Status m_status = Status::NOT_STARTED;
+ Status m_status;
/**
* @brief The self-signed certificate in the request.
*/
diff --git a/src/detail/profile-storage.cpp b/src/detail/profile-storage.cpp
index 8fcbc9f..2917382 100644
--- a/src/detail/profile-storage.cpp
+++ b/src/detail/profile-storage.cpp
@@ -90,7 +90,7 @@
}
const std::list<CaProfile>&
-ProfileStorage::getCaProfiles() const
+ProfileStorage::getKnownProfiles() const
{
return m_caProfiles;
}
diff --git a/src/detail/profile-storage.hpp b/src/detail/profile-storage.hpp
index eabb7c9..5955f15 100644
--- a/src/detail/profile-storage.hpp
+++ b/src/detail/profile-storage.hpp
@@ -28,7 +28,7 @@
namespace requester {
/**
- * @brief Represents Client configuration
+ * @brief CA profiles kept by a requester.
* @sa https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
*/
class ProfileStorage
@@ -53,13 +53,15 @@
removeCaProfile(const Name& caName);
/**
+ * @brief Add a new CA profile
+ *
* Be cautious. This will add a new trust anchor for requesters.
*/
void
addCaProfile(const CaProfile& profile);
const std::list<CaProfile>&
- getCaProfiles() const;
+ getKnownProfiles() const;
private:
std::list<CaProfile> m_caProfiles;
diff --git a/src/name-assignment/assignment-func.hpp b/src/name-assignment/assignment-func.hpp
index 29b516a..9e9b128 100644
--- a/src/name-assignment/assignment-func.hpp
+++ b/src/name-assignment/assignment-func.hpp
@@ -62,7 +62,7 @@
createNameAssignmentFunc(const std::string& challengeType, const std::string& format = "");
NDNCERT_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
- std::vector<std::string> m_nameFormat;
+ std::vector<std::string> m_nameFormat;
private:
typedef function<unique_ptr<NameAssignmentFunc>(const std::string&)> FactoryCreateFunc;
diff --git a/src/requester-request-state.hpp b/src/requester-request-state.hpp
index 9c67409..815e7cc 100644
--- a/src/requester-request-state.hpp
+++ b/src/requester-request-state.hpp
@@ -60,7 +60,7 @@
/**
* @brief The current status of the request.
*/
- Status m_status = Status::NOT_STARTED;
+ Status m_status = Status::BEFORE_CHALLENGE;
/**
* @brief The type of challenge chosen.
*/
diff --git a/src/requester.cpp b/src/requester.cpp
index 6f83dc1..7cfa992 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -19,7 +19,7 @@
*/
#include "requester.hpp"
-#include "identity-challenge/challenge-module.hpp"
+#include "challenge/challenge-module.hpp"
#include "detail/crypto-helpers.hpp"
#include "detail/challenge-encoder.hpp"
#include "detail/error-encoder.hpp"
@@ -290,7 +290,7 @@
void
Requester::endSession(RequestState& state)
{
- if (state.m_status == Status::SUCCESS || state.m_status == Status::ENDED) {
+ if (state.m_status == Status::SUCCESS) {
return;
}
if (state.m_isNewlyCreatedIdentity) {
@@ -303,7 +303,6 @@
auto identity = state.m_keyChain.getPib().getIdentity(state.m_identityName);
state.m_keyChain.deleteKey(identity, state.m_keyPair);
}
- state.m_status = Status::ENDED;
}
void
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 2e0be42..9403c39 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -19,7 +19,7 @@
*/
#include "ca-module.hpp"
-#include "identity-challenge/challenge-pin.hpp"
+#include "challenge/challenge-pin.hpp"
#include "detail/info-encoder.hpp"
#include "requester.hpp"
#include "test-common.hpp"
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index f9b6ba2..da8284c 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -19,9 +19,9 @@
*/
#include "ca-module.hpp"
-#include "identity-challenge/challenge-module.hpp"
-#include "identity-challenge/challenge-email.hpp"
-#include "identity-challenge/challenge-pin.hpp"
+#include "challenge/challenge-module.hpp"
+#include "challenge/challenge-email.hpp"
+#include "challenge/challenge-pin.hpp"
#include "detail/info-encoder.hpp"
#include "requester.hpp"
#include "test-common.hpp"
diff --git a/tests/unit-tests/challenge-credential.t.cpp b/tests/unit-tests/challenge-credential.t.cpp
index 04347ab..4b91aa2 100644
--- a/tests/unit-tests/challenge-credential.t.cpp
+++ b/tests/unit-tests/challenge-credential.t.cpp
@@ -18,7 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
-#include "identity-challenge/challenge-credential.hpp"
+#include "challenge/challenge-credential.hpp"
#include "test-common.hpp"
namespace ndn {
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index 426ea03..34f2089 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -18,7 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
-#include "identity-challenge/challenge-email.hpp"
+#include "challenge/challenge-email.hpp"
#include "test-common.hpp"
namespace ndn {
diff --git a/tests/unit-tests/challenge-pin.t.cpp b/tests/unit-tests/challenge-pin.t.cpp
index 4b87a1e..8366a89 100644
--- a/tests/unit-tests/challenge-pin.t.cpp
+++ b/tests/unit-tests/challenge-pin.t.cpp
@@ -18,7 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
-#include "identity-challenge/challenge-pin.hpp"
+#include "challenge/challenge-pin.hpp"
#include "test-common.hpp"
namespace ndn {
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 9b5c8b5..f193432 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -91,9 +91,9 @@
{
requester::ProfileStorage profileStorage;
profileStorage.load("tests/unit-tests/config-files/config-client-1");
- BOOST_CHECK_EQUAL(profileStorage.getCaProfiles().size(), 2);
+ BOOST_CHECK_EQUAL(profileStorage.getKnownProfiles().size(), 2);
- auto& profile1 = profileStorage.getCaProfiles().front();
+ auto& profile1 = profileStorage.getKnownProfiles().front();
BOOST_CHECK_EQUAL(profile1.m_caPrefix, "/ndn/edu/ucla");
BOOST_CHECK_EQUAL(profile1.m_caInfo, "ndn testbed ca");
BOOST_CHECK_EQUAL(profile1.m_maxValidityPeriod, time::seconds(864000));
@@ -103,7 +103,7 @@
BOOST_CHECK_EQUAL(profile1.m_cert->getName(),
"/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
- auto& profile2 = profileStorage.getCaProfiles().back();
+ auto& profile2 = profileStorage.getKnownProfiles().back();
BOOST_CHECK_EQUAL(profile2.m_caPrefix, "/ndn/edu/ucla/zhiyi");
BOOST_CHECK_EQUAL(profile2.m_caInfo, "");
BOOST_CHECK_EQUAL(profile2.m_maxValidityPeriod, time::seconds(86400));
@@ -134,13 +134,13 @@
item.m_caInfo = "test";
profileStorage.addCaProfile(item);
- BOOST_CHECK_EQUAL(profileStorage.getCaProfiles().size(), 3);
- auto lastItem = profileStorage.getCaProfiles().back();
+ BOOST_CHECK_EQUAL(profileStorage.getKnownProfiles().size(), 3);
+ auto lastItem = profileStorage.getKnownProfiles().back();
BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/test");
profileStorage.removeCaProfile(Name("/test"));
- BOOST_CHECK_EQUAL(profileStorage.getCaProfiles().size(), 2);
- lastItem = profileStorage.getCaProfiles().back();
+ BOOST_CHECK_EQUAL(profileStorage.getKnownProfiles().size(), 2);
+ lastItem = profileStorage.getKnownProfiles().back();
BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/ndn/edu/ucla/zhiyi");
}
diff --git a/tests/unit-tests/protocol-encoders.t.cpp b/tests/unit-tests/protocol-encoders.t.cpp
index a570e6e..c69131b 100644
--- a/tests/unit-tests/protocol-encoders.t.cpp
+++ b/tests/unit-tests/protocol-encoders.t.cpp
@@ -40,7 +40,7 @@
requester::ProfileStorage caCache;
caCache.load("tests/unit-tests/config-files/config-client-1");
- auto& cert = caCache.getCaProfiles().front().m_cert;
+ auto& cert = caCache.getKnownProfiles().front().m_cert;
auto b = infotlv::encodeDataContent(config.m_caProfile, *cert);
auto item = infotlv::decodeDataContent(b);
@@ -104,7 +104,7 @@
{
requester::ProfileStorage caCache;
caCache.load("tests/unit-tests/config-files/config-client-1");
- auto& certRequest = caCache.getCaProfiles().front().m_cert;
+ auto& certRequest = caCache.getKnownProfiles().front().m_cert;
std::vector<uint8_t> pub = ECDHState().getSelfPubKey();
auto b = requesttlv::encodeApplicationParameters(RequestType::REVOKE, pub, *certRequest);
std::vector<uint8_t> returnedPub;
@@ -145,7 +145,7 @@
0xe0, 0xff, 0x56, 0x83, 0xf2, 0x43, 0xb2, 0x13};
requester::ProfileStorage caCache;
caCache.load("tests/unit-tests/config-files/config-client-1");
- security::Certificate certRequest = *caCache.getCaProfiles().front().m_cert;
+ security::Certificate certRequest = *caCache.getKnownProfiles().front().m_cert;
RequestId id = {{102}};
std::array<uint8_t, 16> aesKey;
std::memcpy(aesKey.data(), key, sizeof(key));
@@ -154,7 +154,7 @@
std::move(aesKey), 0);
auto contentBlock = challengetlv::encodeDataContent(state, Name("/ndn/ucla/a/b/c"));
- requester::RequestState context(m_keyChain, caCache.getCaProfiles().front(), RequestType::NEW);
+ requester::RequestState context(m_keyChain, caCache.getKnownProfiles().front(), RequestType::NEW);
context.m_requestId = id;
std::memcpy(context.m_aesKey.data(), key, sizeof(key));
challengetlv::decodeDataContent(contentBlock, context);
diff --git a/tests/unit-tests/requester.t.cpp b/tests/unit-tests/requester.t.cpp
index 4f2c8be..8fc2fe5 100644
--- a/tests/unit-tests/requester.t.cpp
+++ b/tests/unit-tests/requester.t.cpp
@@ -21,7 +21,7 @@
#include "requester.hpp"
#include "detail/error-encoder.hpp"
#include "detail/probe-encoder.hpp"
-#include "identity-challenge/challenge-module.hpp"
+#include "challenge/challenge-module.hpp"
#include "ca-module.hpp"
#include "test-common.hpp"
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 2f4a0b3..d31273d 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -300,7 +300,7 @@
size_t count = 0;
std::cerr << "***************************************\n"
<< "Step " << nStep++ << ": CA SELECTION" << std::endl;
- for (auto item : profileStorage.getCaProfiles()) {
+ for (auto item : profileStorage.getKnownProfiles()) {
std::cerr << "> Index: " << count++ << std::endl
<< ">> CA prefix:" << item.m_caPrefix << std::endl
<< ">> Introduction: " << item.m_caInfo << std::endl;
@@ -341,7 +341,7 @@
std::cerr << "Your input is not an existing index. Exit" << std::endl;
return;
}
- auto itemIterator = profileStorage.getCaProfiles().cbegin();
+ auto itemIterator = profileStorage.getKnownProfiles().cbegin();
std::advance(itemIterator, caIndex);
auto targetCaItem = *itemIterator;
runProbe(targetCaItem);