Loading cli/authcli.cpp +29 −0 Changes for cli/authcli.cpp: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -62,6 +62,32 @@ void addclient(int argc,char **argv){ } void remclient(int argc,char **argv){ cmdplus::CmdController &cmdc=cmdplus::CmdController::getInstance(); cmdc.registerCmd("host-url",'h',true,nullptr,"Server Url"); cmdc.registerCmd("clientid",'i',true,nullptr,"Clientid"); cmdc.parseCmd(argc,argv); if(!cmdc.checkRequired()){ std::cerr << "Not enough arguments" << std::endl; return; } authdb::client::ClientConnection con; con.setUrl(cmdc.getCmdbyKey("host-url")->getValue()); con.setUsername(cmdc.getCmdbyKey("username")->getValue()); con.setUserPassword(cmdc.getCmdbyKey("password")->getValue()); authdb::client::Client clt(con); if(clt.UserAuth()) clt.remConnection(cmdc.getCmdbyKey("clientid")->getValue()); } int main(int argc,char **argv){ if(argc<1){ std::cerr << "Please Enter Command !" << std::endl; Loading @@ -69,6 +95,9 @@ int main(int argc,char **argv){ if(strcmp(argv[1],"addclient")==0){ addclient(argc-1,argv+1); }else if(strcmp(argv[1],"remclient")==0){ remclient(argc-1,argv+1); } } client/client.cpp +29 −0 Changes for client/client.cpp: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -477,3 +477,32 @@ void authdb::client::Client::addConnection(const std::string &clientname,const s resp.push_back('\0'); } void authdb::client::Client::remConnection(const uuid& clientid){ json_object *jresponse = json_object_new_object(); json_object *cmd=json_object_new_array(); json_object *obj=json_object_new_object(); json_object *addclt=json_object_new_object(); json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"remconnection", addclt); json_object_object_add(addclt,"clientname",json_object_new_string(clientid.c_str())); json_object_array_add(cmd,obj); json_object_object_add(jresponse,"commands",cmd); size_t outsize=0; std::vector<char> out; const char *tmp=json_object_to_json_string_length(jresponse,0,&outsize); std::copy(tmp,tmp+outsize,std::back_inserter(out)); libhttppp::HttpRequest nreq; nreq.setHeaderData("accept")->push_back("text/json"); nreq.setRequestURL(_Con._Url.getPath().c_str()); std::vector<char> resp(_Con._Client->Post(nreq,out)); resp.push_back('\0'); } client/client.h +1 −1 Changes for client/client.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ namespace authdb { bool ClientAuth(); void addConnection(const std::string &clientname,const std::string &cltsecret); void remConnection(const std::string &clientname); void remConnection(const uuid &clientid); void SessionInfo(class SessionData &sdat); bool remSession(); Loading Loading
cli/authcli.cpp +29 −0 Changes for cli/authcli.cpp: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -62,6 +62,32 @@ void addclient(int argc,char **argv){ } void remclient(int argc,char **argv){ cmdplus::CmdController &cmdc=cmdplus::CmdController::getInstance(); cmdc.registerCmd("host-url",'h',true,nullptr,"Server Url"); cmdc.registerCmd("clientid",'i',true,nullptr,"Clientid"); cmdc.parseCmd(argc,argv); if(!cmdc.checkRequired()){ std::cerr << "Not enough arguments" << std::endl; return; } authdb::client::ClientConnection con; con.setUrl(cmdc.getCmdbyKey("host-url")->getValue()); con.setUsername(cmdc.getCmdbyKey("username")->getValue()); con.setUserPassword(cmdc.getCmdbyKey("password")->getValue()); authdb::client::Client clt(con); if(clt.UserAuth()) clt.remConnection(cmdc.getCmdbyKey("clientid")->getValue()); } int main(int argc,char **argv){ if(argc<1){ std::cerr << "Please Enter Command !" << std::endl; Loading @@ -69,6 +95,9 @@ int main(int argc,char **argv){ if(strcmp(argv[1],"addclient")==0){ addclient(argc-1,argv+1); }else if(strcmp(argv[1],"remclient")==0){ remclient(argc-1,argv+1); } }
client/client.cpp +29 −0 Changes for client/client.cpp: 29 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -477,3 +477,32 @@ void authdb::client::Client::addConnection(const std::string &clientname,const s resp.push_back('\0'); } void authdb::client::Client::remConnection(const uuid& clientid){ json_object *jresponse = json_object_new_object(); json_object *cmd=json_object_new_array(); json_object *obj=json_object_new_object(); json_object *addclt=json_object_new_object(); json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str())); json_object_object_add(obj,"remconnection", addclt); json_object_object_add(addclt,"clientname",json_object_new_string(clientid.c_str())); json_object_array_add(cmd,obj); json_object_object_add(jresponse,"commands",cmd); size_t outsize=0; std::vector<char> out; const char *tmp=json_object_to_json_string_length(jresponse,0,&outsize); std::copy(tmp,tmp+outsize,std::back_inserter(out)); libhttppp::HttpRequest nreq; nreq.setHeaderData("accept")->push_back("text/json"); nreq.setRequestURL(_Con._Url.getPath().c_str()); std::vector<char> resp(_Con._Client->Post(nreq,out)); resp.push_back('\0'); }
client/client.h +1 −1 Changes for client/client.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ namespace authdb { bool ClientAuth(); void addConnection(const std::string &clientname,const std::string &cltsecret); void remConnection(const std::string &clientname); void remConnection(const uuid &clientid); void SessionInfo(class SessionData &sdat); bool remSession(); Loading