some actual auth with the server and stuff
authorOwen Smith <owen@omsmith.ca>
Tue, 20 Nov 2012 02:26:50 +0000 (21:26 -0500)
committerOwen Smith <owen@omsmith.ca>
Tue, 20 Nov 2012 02:26:50 +0000 (21:26 -0500)
database/gen-cpp/PosBookie_server.skeleton.cpp

index 3119406..2c75465 100644 (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;
       }