Commit 3d5326dc authored by jan.koester's avatar jan.koester
Browse files

fixed line

parent 3672b618
Loading
Loading
Loading
Loading
Loading
+3 −3
Changes for api/addcon.json: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
{
    "commands" : [
        {
            "usersession" : "$usersession",
            "usersession" : "$sessionid",
            "addconnection" : {
                    "clientname" : "dibsi",
                    "clientsecret" : "$clientpassword"
                    "clientname" : "$clientname",
                    "clientsecret" : "$clientsecret"
            }
        }
    ]
+14 −12
Changes for api/curl.sh: 14 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -2,32 +2,34 @@

. ./$1

cllogin () {
    clientlogin=$(sed  -e 's/$clientname/'$(echo $clientname)'/g' -e 's/$clientkey/'$(echo $clientsecret)'/g' clientlogin.json)


    echo $clientlogin

    ret=$(curl -d "$(echo $clientlogin)" "http://$host:$port/api/$domainid" -s --output - )

    echo $ret

    conid=$(echo $ret | grep -oP '"connectionid"\s*:\s*"\K[^"]*' )
}

userlogin () {
    userlogin=$(sed  -e 's/$username/'$(echo $username)'/g' -e 's/$userpassword/'$(echo $userpassword)'/g' -e  's/$clientsession/'$(echo $conid)'/g' userlogin.json)

    ret=$(curl -d "$(echo $userlogin)" "http://$host:$port/api/$domainid" -s --output - )

    sessionid=$(echo $ret | grep -oP '"sessionid"\s*:\s*"\K[^"]*' )

    echo $ret

echo "conid:" $conid
echo "sessionid:" $sessionid
}

if [ $2 = 'checkgpo' ]
then
    cllogin
    userlogin
    checkgpo=$(sed  -e 's/$clientsession/'$(echo $conid)'/g' -e 's/$sessionid/'$(echo  $sessionid)'/g' -e  's/$gpoid/'$(echo $3)'/g' checkgpo.json)
    echo $checkgpo
    ret=$(curl -d "$(echo $checkgpo)" "http://$host:$port/api/$domainid" -s --output - )
    echo $ret
fi

if [ $2 = 'addconnection' ]
then
    userlogin
    addconnection=$(sed  -e 's/$sessionid/'$(echo  $sessionid)'/g' -e  's/$clientname/'$(echo $3)'/g'  -e  's/$clientsecret/'$(echo $4)'/g' addcon.json)
    ret=$(curl -d "$(echo $addconnection)" "http://$host:$port/api/$domainid" -s --output - )
    echo $ret
fi
+7 −3
Changes for src/api.cpp: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -288,8 +288,8 @@ namespace authdb {
            for(int i =0; i<fcount; ++i) {
                json_object_object_foreach(json_object_array_get_idx(cmd,i), key, val) {
                    if(strcmp(key,"addconnection")==0){
                        std::string clientname,clientsecret;
                        int ocount = json_object_object_length(val);
                        std::string clientname,clientsecret;
                        for(int ii =0; ii<ocount; ++ii) {
                            json_object_object_foreach(val,okey,oval){
                                 if(strcmp(okey,"clientname")==0){
@@ -298,7 +298,9 @@ namespace authdb {
                                     clientsecret=json_object_get_string(oval);
                                }
                            }
                        }
                        if(!clientname.empty() && !clientsecret.empty()){
                                std::cout<< "test" << std::endl;
                                uuid gpid;
                                gpid.generate();

@@ -312,7 +314,8 @@ namespace authdb {
                                json_object *respid=json_object_new_object();
                                json_object_object_add(respid,"addclient",json_object_new_string(gpid.c_str()));
                                json_object_array_add(response,respid);
                            }
                                clientname.clear();
                                clientsecret.clear();
                        }
                    }else if(strcmp(key,"remconnection")==0){
                        uuid clientid;
@@ -323,13 +326,14 @@ namespace authdb {
                                     clientid.parse(json_object_get_string(oval));
                                 }
                            }
                        }
                        if(!clientid.empty()){
                            class Client clt;
                            clt.remove(_Backend,clientid);
                            json_object *respid=json_object_new_object();
                            json_object_object_add(respid,"remclient",json_object_new_string(clientid.c_str()));
                            json_object_array_add(response,respid);
                            }
                            clientid.clear();
                        }
                    }
                }
+1 −1
Changes for src/client.cpp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ void authdb::Client::create(AuthBackend& backend, class ClientData* data){
    if(exits(backend,&data->Data.uuid,data->getName(),exi)){
        switch(exi){
            case 1:
                throw authdb::AuthBackendError("Create Client: Username already Exists aborting!");
                throw authdb::AuthBackendError("Create Client: Clientname already Exists aborting!");
            default:
                throw authdb::AuthBackendError("Create Client: UUID already Exists aborting!");
        }