Commit a359a41e authored by jan.koester's avatar jan.koester
Browse files

work on api

parent 8d68eca1
Loading
Loading
Loading
Loading
Loading
+9 −8
Changes for client/client.cpp: 9 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -27,14 +27,12 @@

#include "client.h"

#include "../src/hash/sha512.h"

authdb::ClientConnection::ClientConnection(){
    _Socket=nullptr;
    _Client=nullptr;
}

authdb::ClientConnection::~ClientConnection(){
    delete _Socket;
    delete _Client;
}

void authdb::ClientConnection::setUrl(const char *url){
@@ -54,10 +52,13 @@ void authdb::ClientConnection::setUsername(const char *username){
}

void authdb::ClientConnection::setUserPassword(const char *password){
    sha512 sha;
    sha.hash(password,_UserPasswordHash);
    _UserPassword=password;
}

authdb::Client::Client(ClientConnection& clt) : _Con(clt){
    _Con._Client=new libhttppp::HttpClient(_Con._Url);
}

authdb::Client::Client(ClientConnection& clt){
    _Con=clt;
authdb::Client::~Client(){
    delete _Con._Client;
}
+8 −6
Changes for client/client.h: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@

#include <string>

#include <netplus/socket.h>
#include <httppp/http.h>

#include "../src/uuid.h"
#include "../src/session.h"
@@ -49,9 +49,9 @@ namespace authdb {
        std::string _CltName;
        std::string _CltSecret;
        std::string _UserName;
        std::string _UserPasswordHash;
        std::string _UserPassword;

        netplus::socket *_Socket;
        libhttppp::HttpClient *_Client;
        uuid                            _SessionID;
        uuid                            _ClientId;
        friend class Client;
@@ -60,6 +60,8 @@ namespace authdb {
    class Client {
    public:
        Client(ClientConnection &clt);
        ~Client();

        bool UserAuth();
        bool ClientAuth();

@@ -68,14 +70,14 @@ namespace authdb {
            void add(const std::string &clientname,const std::string &cltsecret);
            void rem(const std::string &clientname);
            bool check(const std::string &clientname);
        };
        } CCon;

        class GPO {
        public:
            bool check(uuid gpoid,const SessionData &sdat);
        };
        } CGPO;

    private:
        ClientConnection _Con;
        ClientConnection &_Con;
    };
};