some actual auth with the server and stuff

This commit is contained in:
Owen Smith 2012-11-19 21:26:50 -05:00
parent 56e5c4569c
commit 720697bf7e
1 changed files with 8 additions and 1 deletions

View File

@ -11,6 +11,7 @@
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include "sha1.h"
#include <stdio.h>
using namespace ::apache::thrift;
@ -29,6 +30,12 @@ class PosBookieHandler : virtual public PosBookieIf {
shared_ptr<TProtocol> protocol;
PosClient client;
std::string getAuthString() {
std::string s;
this->client.getSalt(s);
return SHA1Hash(s+"PSK").toHex();
}
public:
PosBookieHandler(char* serverHost, int serverPort)
: socket(new TSocket(serverHost, serverPort))
@ -60,7 +67,7 @@ class PosBookieHandler : virtual public PosBookieIf {
int32_t accountBalance = this->client.getHashAccountBalance(dataToHash);
if(accountBalance < total_price) {
this->client.performTransactionOnHash("AUTH", dataToHash, total_price * -1);
this->client.performTransactionOnHash(this->getAuthString(), dataToHash, total_price * -1);
return E_PURCHASE_STATUS::type::EPS_SUCCESS;
}