Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed uniqueCPUID
Fork of bcsdk by
MockHsm.cpp
- Committer:
- webmaster
- Date:
- 2017-09-21
- Revision:
- 8:f2a567ee3a46
- Child:
- 10:aabd720e632c
File content as of revision 8:f2a567ee3a46:
#include "MockHsm.h"
MockHsm::MockHsm()
{
alias = "";
client_token = "962cd39d-6496-4b23-a2c5-85e445069a78";
}
MockHsm::~MockHsm()
{
alias = "";
client_token = "";
}
string MockHsm::getAlias()
{
return this->alias;
}
void MockHsm::setAlias(string newAlias)
{
this->alias = newAlias;
}
string MockHsm::createKey()
{
string strJson = "";
MbedJSONValue val;
//fill the object
val["alias"] = this->alias;
val["client_token"] = this->client_token;
//serialize it into a JSON string
strJson = val.serialize();
printf("json: %s\r\n", strJson.c_str());
string strRep = "";
string strUrl = "/create-key";
client.http_post(strUrl,strJson,strRep);
//cout<< "HTTP Response:\n" << strRep.length() << endl << strRep.c_str() << endl;
return strJson;
}
string MockHsm::listKeys()
{
string strJson = "";
MbedJSONValue val;
//serialize it into a JSON string
strJson = val.serialize();
if ("null" == strJson)
{
strJson = "{}";
}
//printf("json: %s\r\n", strJson.c_str());
string strRep = "";
string strUrl = "/mockhsm/list-keys";
client.http_post(strUrl,strJson,strRep);
//cout<< "HTTP Response:\n" << strRep.length() << endl << strRep.c_str() << endl;
return strJson;
}
