use namespace for ca and rename CaState to ca::RequestState

Change-Id: I2250bf7fb68503465dae18e16dc3c512fe809037
diff --git a/src/identity-challenge/challenge-credential.cpp b/src/identity-challenge/challenge-credential.cpp
index 9cceefe..e4f21d4 100644
--- a/src/identity-challenge/challenge-credential.cpp
+++ b/src/identity-challenge/challenge-credential.cpp
@@ -75,7 +75,7 @@
 
 // For CA
 std::tuple<ErrorCode, std::string>
-ChallengeCredential::handleChallengeRequest(const Block& params, CaState& request)
+ChallengeCredential::handleChallengeRequest(const Block& params, ca::RequestState& request)
 {
   params.parse();
   if (m_trustAnchors.empty()) {
diff --git a/src/identity-challenge/challenge-credential.hpp b/src/identity-challenge/challenge-credential.hpp
index 38a7e1a..17bc979 100644
--- a/src/identity-challenge/challenge-credential.hpp
+++ b/src/identity-challenge/challenge-credential.hpp
@@ -53,7 +53,7 @@
 
   // For CA
   std::tuple<ErrorCode, std::string>
-  handleChallengeRequest(const Block& params, CaState& request) override;
+  handleChallengeRequest(const Block& params, ca::RequestState& request) override;
 
   // For Client
   std::vector<std::tuple<std::string, std::string>>
diff --git a/src/identity-challenge/challenge-email.cpp b/src/identity-challenge/challenge-email.cpp
index cc141dc..be7cd2a 100644
--- a/src/identity-challenge/challenge-email.cpp
+++ b/src/identity-challenge/challenge-email.cpp
@@ -43,7 +43,7 @@
 
 // For CA
 std::tuple<ErrorCode, std::string>
-ChallengeEmail::handleChallengeRequest(const Block& params, CaState& request)
+ChallengeEmail::handleChallengeRequest(const Block& params, ca::RequestState& request)
 {
   params.parse();
   auto currentTime = time::system_clock::now();
@@ -157,7 +157,7 @@
 
 void
 ChallengeEmail::sendEmail(const std::string& emailAddress, const std::string& secret,
-                          const CaState& request) const
+                          const ca::RequestState& request) const
 {
   std::string command = m_sendEmailScript;
   command += " \"" + emailAddress + "\" \"" + secret + "\" \"" + request.m_caPrefix.toUri() + "\" \"" + request.m_cert.getName().toUri() + "\"";
diff --git a/src/identity-challenge/challenge-email.hpp b/src/identity-challenge/challenge-email.hpp
index 8fc6af5..9dbcedd 100644
--- a/src/identity-challenge/challenge-email.hpp
+++ b/src/identity-challenge/challenge-email.hpp
@@ -57,7 +57,7 @@
 
   // For CA
   std::tuple<ErrorCode, std::string>
-  handleChallengeRequest(const Block& params, CaState& request) override;
+  handleChallengeRequest(const Block& params, ca::RequestState& request) override;
 
   // For Client
   std::vector<std::tuple<std::string, std::string>>
@@ -81,7 +81,7 @@
 
   void
   sendEmail(const std::string& emailAddress, const std::string& secret,
-            const CaState& request) const;
+            const ca::RequestState& request) const;
 
 private:
   std::string m_sendEmailScript;
diff --git a/src/identity-challenge/challenge-module.cpp b/src/identity-challenge/challenge-module.cpp
index 03feeeb..2208e83 100644
--- a/src/identity-challenge/challenge-module.cpp
+++ b/src/identity-challenge/challenge-module.cpp
@@ -73,7 +73,7 @@
 }
 
 std::tuple<ErrorCode, std::string>
-ChallengeModule::returnWithError(CaState& request, ErrorCode errorCode, std::string&& errorInfo)
+ChallengeModule::returnWithError(ca::RequestState& request, ErrorCode errorCode, std::string&& errorInfo)
 {
   request.m_status = Status::FAILURE;
   request.m_challengeType = "";
@@ -82,17 +82,17 @@
 }
 
 std::tuple<ErrorCode, std::string>
-ChallengeModule::returnWithNewChallengeStatus(CaState& request, const std::string& challengeStatus,
+ChallengeModule::returnWithNewChallengeStatus(ca::RequestState& request, const std::string& challengeStatus,
                                               JsonSection&& challengeSecret, size_t remainingTries, time::seconds remainingTime)
 {
   request.m_status = Status::CHALLENGE;
   request.m_challengeType = CHALLENGE_TYPE;
-  request.m_challengeState = ChallengeState(challengeStatus, time::system_clock::now(), remainingTries, remainingTime, std::move(challengeSecret));
+  request.m_challengeState = ca::ChallengeState(challengeStatus, time::system_clock::now(), remainingTries, remainingTime, std::move(challengeSecret));
   return std::make_tuple(ErrorCode::NO_ERROR, "");
 }
 
 std::tuple<ErrorCode, std::string>
-ChallengeModule::returnWithSuccess(CaState& request)
+ChallengeModule::returnWithSuccess(ca::RequestState& request)
 {
   request.m_status = Status::PENDING;
   request.m_challengeType = CHALLENGE_TYPE;
diff --git a/src/identity-challenge/challenge-module.hpp b/src/identity-challenge/challenge-module.hpp
index 22c6a4c..f1c942f 100644
--- a/src/identity-challenge/challenge-module.hpp
+++ b/src/identity-challenge/challenge-module.hpp
@@ -51,7 +51,7 @@
 
   // For CA
   virtual std::tuple<ErrorCode, std::string>
-  handleChallengeRequest(const Block& params, CaState& request) = 0;
+  handleChallengeRequest(const Block& params, ca::RequestState& request) = 0;
 
   // For Client
   virtual std::vector<std::tuple<std::string, std::string>>
@@ -68,14 +68,14 @@
 protected:
   // used by challenge modules
   std::tuple<ErrorCode, std::string>
-  returnWithError(CaState& request, ErrorCode errorCode, std::string&& errorInfo);
+  returnWithError(ca::RequestState& request, ErrorCode errorCode, std::string&& errorInfo);
 
   std::tuple<ErrorCode, std::string>
-  returnWithNewChallengeStatus(CaState& request, const std::string& challengeStatus,
+  returnWithNewChallengeStatus(ca::RequestState& request, const std::string& challengeStatus,
                                JsonSection&& challengeSecret, size_t remainingTries, time::seconds remainingTime);
 
   std::tuple<ErrorCode, std::string>
-  returnWithSuccess(CaState& request);
+  returnWithSuccess(ca::RequestState& request);
 
 public:
   const std::string CHALLENGE_TYPE;
diff --git a/src/identity-challenge/challenge-pin.cpp b/src/identity-challenge/challenge-pin.cpp
index c9f98ba..726771f 100644
--- a/src/identity-challenge/challenge-pin.cpp
+++ b/src/identity-challenge/challenge-pin.cpp
@@ -38,7 +38,7 @@
 
 // For CA
 std::tuple<ErrorCode, std::string>
-ChallengePin::handleChallengeRequest(const Block& params, CaState& request)
+ChallengePin::handleChallengeRequest(const Block& params, ca::RequestState& request)
 {
   params.parse();
   auto currentTime = time::system_clock::now();
diff --git a/src/identity-challenge/challenge-pin.hpp b/src/identity-challenge/challenge-pin.hpp
index b942c4d..10b23d4 100644
--- a/src/identity-challenge/challenge-pin.hpp
+++ b/src/identity-challenge/challenge-pin.hpp
@@ -52,7 +52,7 @@
 
   // For CA
   std::tuple<ErrorCode, std::string>
-  handleChallengeRequest(const Block& params, CaState& request) override;
+  handleChallengeRequest(const Block& params, ca::RequestState& request) override;
 
   // For Client
   std::vector<std::tuple<std::string, std::string>>