Fixes

parent e0b46c47
......@@ -35,41 +35,6 @@ SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
serverVersion_t type)
: AbstractStubServer(connector, type) {}
void SGXWalletServer::notifyServer() { cout << "Server got notified" << endl; }
string SGXWalletServer::sayHello(const string &name) {
if (name == "")
throw JsonRpcException(-32100, "Name was empty");
return "Hello " + name;
}
int SGXWalletServer::addNumbers(int param1, int param2) { return param1 + param2; }
double SGXWalletServer::addNumbers2(double param1, double param2) {
return param1 + param2;
}
bool SGXWalletServer::isEqual(const string &str1, const string &str2) {
return str1 == str2;
}
Json::Value SGXWalletServer::buildObject(const string &name, int age) {
Json::Value result;
result["name"] = name;
result["year"] = age;
return result;
}
string SGXWalletServer::methodWithoutParameters() { return "Test"; }
int init_server() {
HttpServer httpserver(1025);
SGXWalletServer s(httpserver,
......
......@@ -15,14 +15,6 @@ class SGXWalletServer : public AbstractStubServer {
public:
SGXWalletServer(AbstractServerConnector &connector, serverVersion_t type);
virtual void notifyServer();
virtual std::string sayHello(const std::string &name);
virtual int addNumbers(int param1, int param2);
virtual double addNumbers2(double param1, double param2);
virtual bool isEqual(const std::string &str1, const std::string &str2);
virtual Json::Value buildObject(const std::string &name, int age);
virtual std::string methodWithoutParameters();
virtual Json::Value importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t);
virtual Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash);
virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName);
......
......@@ -17,13 +17,6 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
this->bindAndAddMethod(jsonrpc::Procedure("importECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "key",jsonrpc::JSON_STRING,"keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::importECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("generateECDSAKey", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "keyName",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::generateECDSAKeyI);
this->bindAndAddMethod(jsonrpc::Procedure("ecdsaSignMessageHash", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "keyShareName",jsonrpc::JSON_STRING,"messageHash",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::ecdsaSignMessageHashI);
this->bindAndAddMethod(jsonrpc::Procedure("sayHello", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "name",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::sayHelloI);
this->bindAndAddNotification(jsonrpc::Procedure("notifyServer", jsonrpc::PARAMS_BY_NAME, NULL), &AbstractStubServer::notifyServerI);
this->bindAndAddMethod(jsonrpc::Procedure("addNumbers", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_INTEGER, "param1",jsonrpc::JSON_INTEGER,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::addNumbersI);
this->bindAndAddMethod(jsonrpc::Procedure("addNumbers2", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_REAL, "param1",jsonrpc::JSON_REAL,"param2",jsonrpc::JSON_REAL, NULL), &AbstractStubServer::addNumbers2I);
this->bindAndAddMethod(jsonrpc::Procedure("isEqual", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::isEqualI);
this->bindAndAddMethod(jsonrpc::Procedure("buildObject", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_OBJECT, "param1",jsonrpc::JSON_STRING,"param2",jsonrpc::JSON_INTEGER, NULL), &AbstractStubServer::buildObjectI);
this->bindAndAddMethod(jsonrpc::Procedure("methodWithoutParameters", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractStubServer::methodWithoutParametersI);
}
inline virtual void importBLSKeyShareI(const Json::Value &request, Json::Value &response)
......@@ -46,48 +39,11 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
{
response = this->ecdsaSignMessageHash(request["keyShareName"].asString(), request["messageHash"].asString());
}
inline virtual void sayHelloI(const Json::Value &request, Json::Value &response)
{
response = this->sayHello(request["name"].asString());
}
inline virtual void notifyServerI(const Json::Value &request)
{
(void)request;
this->notifyServer();
}
inline virtual void addNumbersI(const Json::Value &request, Json::Value &response)
{
response = this->addNumbers(request[0u].asInt(), request[1u].asInt());
}
inline virtual void addNumbers2I(const Json::Value &request, Json::Value &response)
{
response = this->addNumbers2(request[0u].asDouble(), request[1u].asDouble());
}
inline virtual void isEqualI(const Json::Value &request, Json::Value &response)
{
response = this->isEqual(request[0u].asString(), request[1u].asString());
}
inline virtual void buildObjectI(const Json::Value &request, Json::Value &response)
{
response = this->buildObject(request[0u].asString(), request[1u].asInt());
}
inline virtual void methodWithoutParametersI(const Json::Value &request, Json::Value &response)
{
(void)request;
response = this->methodWithoutParameters();
}
virtual Json::Value importBLSKeyShare(int index, const std::string& keyShare, const std::string& keyShareName, int n, int t) = 0;
virtual Json::Value blsSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0;
virtual Json::Value importECDSAKey(const std::string& key, const std::string& keyName) = 0;
virtual Json::Value generateECDSAKey(const std::string& keyName) = 0;
virtual Json::Value ecdsaSignMessageHash(const std::string& keyShareName, const std::string& messageHash) = 0;
virtual std::string sayHello(const std::string& name) = 0;
virtual void notifyServer() = 0;
virtual int addNumbers(int param1, int param2) = 0;
virtual double addNumbers2(double param1, double param2) = 0;
virtual bool isEqual(const std::string& param1, const std::string& param2) = 0;
virtual Json::Value buildObject(const std::string& param1, int param2) = 0;
virtual std::string methodWithoutParameters() = 0;
};
#endif //JSONRPC_CPP_STUB_ABSTRACTSTUBSERVER_H_
......@@ -68,56 +68,5 @@
"errorMessage": "12345",
"signature": "12345"
}
},
{
"name": "sayHello",
"params": {
"name": "Peter"
},
"returns": "Hello Peter"
},
{
"name": "notifyServer"
},
{
"name": "addNumbers",
"params": [
3,
4
],
"returns": 7
},
{
"name": "addNumbers2",
"params": [
3.2,
4.1
],
"returns": 7.5
},
{
"name": "isEqual",
"params": [
"string1",
"string2"
],
"returns": false
},
{
"name": "buildObject",
"params": [
"peter",
1990
],
"returns": {
"name": "peter",
"year": 1990
}
},
{
"name": "methodWithoutParameters",
"returns": "String"
}
]
\ No newline at end of file
......@@ -69,76 +69,6 @@ class StubClient : public jsonrpc::Client
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string sayHello(const std::string& name) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p["name"] = name;
Json::Value result = this->CallMethod("sayHello",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
void notifyServer() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
this->CallNotification("notifyServer",p);
}
int addNumbers(int param1, int param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("addNumbers",p);
if (result.isIntegral())
return result.asInt();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
double addNumbers2(double param1, double param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("addNumbers2",p);
if (result.isDouble())
return result.asDouble();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
bool isEqual(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("isEqual",p);
if (result.isBool())
return result.asBool();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
Json::Value buildObject(const std::string& param1, int param2) throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p.append(param1);
p.append(param2);
Json::Value result = this->CallMethod("buildObject",p);
if (result.isObject())
return result;
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
std::string methodWithoutParameters() throw (jsonrpc::JsonRpcException)
{
Json::Value p;
p = Json::nullValue;
Json::Value result = this->CallMethod("methodWithoutParameters",p);
if (result.isString())
return result.asString();
else
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
}
};
#endif //JSONRPC_CPP_STUB_STUBCLIENT_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment