Adding json

parent 36737159
...@@ -24,4 +24,5 @@ EXTERNC bool hex2carray(const char * _hex, uint64_t *_bin_len, ...@@ -24,4 +24,5 @@ EXTERNC bool hex2carray(const char * _hex, uint64_t *_bin_len,
#endif //SGXD_BLSCRYPTO_H #endif //SGXD_BLSCRYPTO_H
...@@ -38,7 +38,7 @@ SUBDIRS=secure_enclave ...@@ -38,7 +38,7 @@ SUBDIRS=secure_enclave
secure_enclave.edl: secure_enclave/secure_enclave.edl secure_enclave.edl: secure_enclave/secure_enclave.edl
ln -s $? ln -s $?
cd /s
## Additional automake variables ## Additional automake variables
## ##
## AM_CPPFLAGS += ## AM_CPPFLAGS +=
...@@ -65,7 +65,7 @@ bin_PROGRAMS = sgxwallet testw ...@@ -65,7 +65,7 @@ bin_PROGRAMS = sgxwallet testw
COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwallet.c BLSCrypto.cpp BLSPrivateKeyShareSGX.cpp $(COMMON_SRC) sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp BLSCrypto.cpp BLSPrivateKeyShareSGX.cpp $(COMMON_SRC)
nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC) nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC)
EXTRA_sgxwallet_DEPENDENCIES = secure_enclave.signed.so EXTRA_sgxwallet_DEPENDENCIES = secure_enclave.signed.so
......
//
// Created by kladko on 05.09.19.
//
/*************************************************************************
* libjson-rpc-cpp
*************************************************************************
* @file stubserver.cpp
* @date 02.05.2013
* @author Peter Spiess-Knafl <dev@spiessknafl.at>
* @license See attached LICENSE.txt
************************************************************************/
#include <iostream>
#include "abstractstubserver.h"
#include <jsonrpccpp/server/connectors/httpserver.h>
#include <stdio.h>
#include "SGXWalletServer.h"
using namespace jsonrpc;
using namespace std;
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();
};
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(8383);
SGXWalletServer s(httpserver,
JSONRPC_SERVER_V1V2); // hybrid server (json-rpc 1.0 & 2.0)
s.StartListening();
cout << "Hit enter to stop the server" << endl;
getchar();
s.StopListening();
return 0;
}
\ No newline at end of file
//
// Created by kladko on 05.09.19.
//
#ifndef SGXD_SGXWALLETSERVER_H
#define SGXD_SGXWALLETSERVER_H
#endif //SGXD_SGXWALLETSERVER_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