combine requester state
Change-Id: If91d08318ec1a40a8c031fdd493fe1f8662ef35d
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 66801b2..816ec34 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -18,7 +18,7 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
-#include "requester.hpp"
+#include "requester-request.hpp"
#include <ndn-cxx/security/verification-helpers.hpp>
#include <boost/asio.hpp>
#include <boost/program_options/options_description.hpp>
@@ -43,7 +43,7 @@
size_t nStep = 1;
Face face;
security::KeyChain keyChain;
-shared_ptr<RequestState> requesterState = nullptr;
+shared_ptr<Request> requesterState = nullptr;
static void
captureParams(std::multimap<std::string, std::string>& requirement)
@@ -111,7 +111,7 @@
static void
certFetchCb(const Data& reply)
{
- auto item = Requester::onCertFetchResponse(reply);
+ auto item = Request::onCertFetchResponse(reply);
if (item) {
keyChain.addCertificate(keyChain.getPib().getIdentity(item->getIdentity()).getKey(item->getKeyName()), *item);
}
@@ -127,7 +127,7 @@
challengeCb(const Data& reply)
{
try {
- Requester::onChallengeResponse(*requesterState, reply);
+ requesterState->onChallengeResponse(reply);
}
catch (const std::exception& e) {
std::cerr << "Error when decoding challenge step: " << e.what() << std::endl;
@@ -135,7 +135,7 @@
}
if (requesterState->status == Status::SUCCESS) {
std::cerr << "Certificate has already been issued, downloading certificate..." << std::endl;
- face.expressInterest(*Requester::genCertFetchInterest(*requesterState), bind(&certFetchCb, _2),
+ face.expressInterest(*requesterState->genCertFetchInterest(), bind(&certFetchCb, _2),
bind(&onNackCb), bind(&timeoutCb));
return;
}
@@ -147,7 +147,7 @@
{
std::list<std::string> challengeList;
try {
- challengeList = Requester::onNewRenewRevokeResponse(*requesterState, reply);
+ challengeList = requesterState->onNewRenewRevokeResponse(reply);
}
catch (const std::exception& e) {
std::cerr << "Error on decoding NEW step reply because: " << e.what() << std::endl;
@@ -205,10 +205,10 @@
optional<CaProfile> profile;
try {
if (certFullName.empty()) {
- profile = Requester::onCaProfileResponse(reply);
+ profile = Request::onCaProfileResponse(reply);
}
else {
- profile = Requester::onCaProfileResponseAfterRedirection(reply, certFullName);
+ profile = Request::onCaProfileResponseAfterRedirection(reply, certFullName);
}
}
catch (const std::exception& e) {
@@ -242,7 +242,7 @@
{
std::vector<std::pair<Name, int>> names;
std::vector<Name> redirects;
- Requester::onProbeResponse(reply, profile, names, redirects);
+ Request::onProbeResponse(reply, profile, names, redirects);
size_t count = 0;
std::cerr << "\n***************************************\n"
<< "Step " << nStep++
@@ -298,9 +298,9 @@
auto redirectedCaName = security::extractIdentityFromCertName(redirectedCaFullName.getPrefix(-1));
std::cerr << "You selected to be redirected to CA: " << redirectedCaName.toUri() << std::endl;
face.expressInterest(
- *Requester::genCaProfileDiscoveryInterest(redirectedCaName),
+ *Request::genCaProfileDiscoveryInterest(redirectedCaName),
[&](const Interest&, const Data& data) {
- auto fetchingInterest = Requester::genCaProfileInterestFromDiscoveryResponse(data);
+ auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data);
face.expressInterest(*fetchingInterest,
bind(&InfoCb, _2, redirectedCaFullName),
bind(&onNackCb),
@@ -342,9 +342,9 @@
std::string expectedCAName;
getline(std::cin, expectedCAName);
face.expressInterest(
- *Requester::genCaProfileDiscoveryInterest(Name(expectedCAName)),
+ *Request::genCaProfileDiscoveryInterest(Name(expectedCAName)),
[&](const Interest&, const Data& data) {
- auto fetchingInterest = Requester::genCaProfileInterestFromDiscoveryResponse(data);
+ auto fetchingInterest = Request::genCaProfileInterestFromDiscoveryResponse(data);
face.expressInterest(*fetchingInterest,
bind(&InfoCb, _2, Name()),
bind(&onNackCb),
@@ -405,7 +405,7 @@
std::cerr << "\n***************************************\n"
<< "Step " << nStep++ << ": Please provide information for name assignment" << std::endl;
auto capturedParams = captureParams(profile.probeParameterKeys);
- face.expressInterest(*Requester::genProbeInterest(profile, std::move(capturedParams)),
+ face.expressInterest(*Request::genProbeInterest(profile, std::move(capturedParams)),
bind(&probeCb, _2, profile), bind(&onNackCb), bind(&timeoutCb));
}
else {
@@ -425,8 +425,8 @@
int validityPeriod = captureValidityPeriod();
auto now = time::system_clock::now();
std::cerr << "The validity period of your certificate will be: " << validityPeriod << " hours" << std::endl;
- requesterState = std::make_shared<RequestState>(keyChain, profile, RequestType::NEW);
- auto interest = Requester::genNewInterest(*requesterState, identityName, now, now + time::hours(validityPeriod));
+ requesterState = std::make_shared<Request>(keyChain, profile, RequestType::NEW);
+ auto interest = requesterState->genNewInterest(identityName, now, now + time::hours(validityPeriod));
if (interest != nullptr) {
face.expressInterest(*interest, bind(&newCb, _2), bind(&onNackCb), bind(&timeoutCb));
}
@@ -440,7 +440,7 @@
{
std::multimap<std::string, std::string> requirement;
try {
- requirement = Requester::selectOrContinueChallenge(*requesterState, challengeType);
+ requirement = requesterState->selectOrContinueChallenge(challengeType);
}
catch (const std::exception& e) {
std::cerr << "Error. Cannot successfully load the Challenge Module with error: " << std::string(e.what())
@@ -453,7 +453,7 @@
<< ": Please provide parameters used for Identity Verification Challenge" << std::endl;
captureParams(requirement);
}
- face.expressInterest(*Requester::genChallengeInterest(*requesterState, std::move(requirement)),
+ face.expressInterest(*requesterState->genChallengeInterest(std::move(requirement)),
bind(&challengeCb, _2), bind(&onNackCb), bind(&timeoutCb));
}
@@ -473,7 +473,7 @@
}
std::cerr << std::endl;
if (requesterState) {
- Requester::endSession(*requesterState);
+ requesterState->endSession();
}
face.getIoService().stop();
exit(1);