二期c++接口
Dependencies: EthernetInterface 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; }