Merge pull request #10 in MM/mpin-sdk-core from feature/get_session_details to master

* commit '9640f6eaf631921db375cb70a6f7504181c1549f':
  Provide SDK API to get authentication session details
diff --git a/src/mpin_sdk.cpp b/src/mpin_sdk.cpp
index ad86a75..65608aa 100644
--- a/src/mpin_sdk.cpp
+++ b/src/mpin_sdk.cpp
@@ -405,6 +405,7 @@
     case GET_CLIENT_SETTINGS:
     case AUTHENTICATE_PASS1:
     case AUTHENTICATE_PASS2:
+    case GET_SESSION_DETAILS:
         break;
     case REGISTER:
         if(m_httpStatus == HTTP_FORBIDDEN)
@@ -1332,18 +1333,27 @@
     return calculatedCheckSum == checkSum;
 }
 
-String MPinSDK::GetPrerollUserId(const String& accessCode)
+void MPinSDK::SessionDetails::Clear()
 {
+    prerollId.clear();
+    appName.clear();
+    appIconUrl.clear();
+}
+
+Status MPinSDK::GetSessionDetails(const String& accessCode, OUT SessionDetails& sessionDetails)
+{
+    sessionDetails.Clear();
+
     Status s = CheckIfBackendIsSet();
     if(s != Status::OK)
     {
-        return "";
+        return s;
     }
 
     String codeStatusUrl = m_clientSettings.GetStringParam("codeStatusURL");
     if(codeStatusUrl.empty())
     {
-        return "";
+        return Status::OK;
     }
 
     util::JsonObject data;
@@ -1353,10 +1363,15 @@
     HttpResponse response = MakeRequest(codeStatusUrl, IHttpRequest::POST, data);
     if(response.GetStatus() != HttpResponse::HTTP_OK)
     {
-        return "";
+        return response.TranslateToMPinStatus(HttpResponse::GET_SESSION_DETAILS);
     }
 
-    return response.GetJsonData().GetStringParam("prerollId");
+    const util::JsonObject& json = response.GetJsonData();
+    sessionDetails.prerollId = json.GetStringParam("prerollId");
+    sessionDetails.appName = json.GetStringParam("appName");
+    sessionDetails.appIconUrl = json.GetStringParam("appLogoURL");
+
+    return Status::OK;
 }
 
 void MPinSDK::DeleteUser(UserPtr user)
diff --git a/src/mpin_sdk.h b/src/mpin_sdk.h
index f5f77b6..bd7a2f1 100644
--- a/src/mpin_sdk.h
+++ b/src/mpin_sdk.h
@@ -221,6 +221,16 @@
 		Status status;
 	};
 
+    class SessionDetails
+    {
+    public:
+        void Clear();
+
+        String prerollId;
+        String appName;
+        String appIconUrl;
+    };
+
     MPinSDK();
     ~MPinSDK();
     Status Init(const StringMap& config, IN IContext* ctx);
@@ -243,7 +253,7 @@
     Status FinishAuthenticationOTP(INOUT UserPtr user, const String& pin, OUT OTP& otp);
     Status FinishAuthenticationAN(INOUT UserPtr user, const String& pin, const String& accessNumber);
 
-    String GetPrerollUserId(const String& accessCode);
+    Status GetSessionDetails(const String& accessCode, OUT SessionDetails& sessionDetails);
 
     void DeleteUser(INOUT UserPtr user);
     void DeleteUser(INOUT UserPtr user, const String& backend);
@@ -282,6 +292,7 @@
             AUTHENTICATE_PASS1,
             AUTHENTICATE_PASS2,
             AUTHENTICATE_RPA,
+            GET_SESSION_DETAILS,
         };
 
         enum DataType
diff --git a/tests/cmdline_test.cpp b/tests/cmdline_test.cpp
index 685a37a..d08336b 100644
--- a/tests/cmdline_test.cpp
+++ b/tests/cmdline_test.cpp
@@ -82,7 +82,7 @@
     }
 
     bool testMaasWorkflow = false;
-    const char *maasBackend = "http://192.168.98.141:8001";
+    const char *maasBackend = "http://mpinaas-demo.miracl.net:8001";
     if(testMaasWorkflow)
     {
         s = sdk.SetBackend(maasBackend);
@@ -161,8 +161,17 @@
     {
         cout << "Enter access code: ";
         cin >> accessCode;
-        MPinSDK::String userId = sdk.GetPrerollUserId(accessCode);
-        cout << "GetPrerollUserId() returned '" << userId << "'. Press any key to continue..." << endl;
+        MPinSDK::SessionDetails sd;
+        s = sdk.GetSessionDetails(accessCode, sd);
+        if(s == MPinSDK::Status::OK)
+        {
+            cout << "GetSessionDetails() returned prerollId = '"
+                << sd.prerollId << "' appName = '" << sd.appName << "' appIconUrl = '" << sd.appIconUrl << "'" << endl;
+        }
+        else
+        {
+            cout << "ERROR: GetSessionDetails() returned status = " << s.GetStatusCode() << ", error = '" << s.GetErrorMessage() << "'" << endl;
+        }
     }
 
     s = sdk.StartAuthentication(user, accessCode);