X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=authserver%2Flib%2FauthClient.php;h=9b8480f38c1a6991a88c9d643332398864b724e6;hb=c3c37cd9f486175adf0351de80c19efd02892ca6;hp=a3a2172990192060e551e8e3a12a5d32ab3807ef;hpb=3354ed0d5c9f3877ac2222ac25326acd05d3d236;p=ga4php.git diff --git a/authserver/lib/authClient.php b/authserver/lib/authClient.php index a3a2172..9b8480f 100644 --- a/authserver/lib/authClient.php +++ b/authserver/lib/authClient.php @@ -3,8 +3,35 @@ require_once("lib.php"); class GAAuthClient { + function addRadiusClient($clientname, $clientip, $clientsecret, $clientdesc) { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + - function setUserToken($username, $token) { + $message["clientname"] = $clientname; + $message["clientsecret"] = $clientsecret; + $message["clientip"] = $clientip; + $message["clientdescription"] = $clientdesc; + + msg_send($sr_queue, MSG_ADD_RADIUS_CLIENT, $message, true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + return $msg; + } + + function syncUserToken($username, $tokenone, $tokentwo) { global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; @@ -21,16 +48,61 @@ class GAAuthClient { $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); $message["username"] = $username; - $message["token"] = $token; + $message["tokenone"] = $tokenone; + $message["tokentwo"] = $tokentwo; + + msg_send($sr_queue, MSG_SYNC_TOKEN, $message, true, true, $msg_err); - msg_send($sr_queue, MSG_SET_USER_TOKEN, $message, true, true, $msg_err); - echo "message sent\n"; + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + return $msg; + } + + function getUserTokenType($username) { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + + $message["username"] = $username; + msg_send($sr_queue, MSG_GET_TOKEN_TYPE, $message, true, true, $msg_err); msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); + return $msg; + } + + function setUserToken($username, $token) { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + $message["username"] = $username; + $message["tokenstring"] = $token; + msg_send($sr_queue, MSG_SET_USER_TOKEN, $message, true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + return $msg; } function setUserPass($username, $password) { @@ -53,12 +125,62 @@ class GAAuthClient { $message["password"] = $password; msg_send($sr_queue, MSG_SET_USER_PASSWORD, $message, true, true, $msg_err); - echo "message sent\n"; msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); + + return $msg; + } + + function getOtkID($username) { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + + $message["username"] = $username; + msg_send($sr_queue, MSG_GET_OTK_ID, $message, true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + + return $msg; + + } + function getOtkPng($username, $otk) { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + + $message["otk"] = $otk; + $message["username"] = $username; + error_log("sending message, $otk"); + msg_send($sr_queue, MSG_GET_OTK_PNG, $message, true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + + return $msg; + } function authUserPass($username, $password) { @@ -81,12 +203,9 @@ class GAAuthClient { $message["password"] = $password; msg_send($sr_queue, MSG_AUTH_USER_PASSWORD, $message, true, true, $msg_err); - echo "message sent\n"; msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); - + return $msg; } function deleteUser($username) { @@ -108,11 +227,10 @@ class GAAuthClient { $message["username"] = $username; msg_send($sr_queue, MSG_DELETE_USER, $message, true, true, $msg_err); - echo "message sent\n"; msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); + + return $msg; } @@ -136,12 +254,32 @@ class GAAuthClient { $message["realname"] = $realname; msg_send($sr_queue, MSG_SET_USER_REALNAME, $message, true, true, $msg_err); - echo "message sent\n"; msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); + return $msg; + } + + function getUsers() { + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + + msg_send($sr_queue, MSG_GET_USERS, "", true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 524288, $msg); + return $msg; } function authUserToken($username, $passcode) { @@ -164,17 +302,41 @@ class GAAuthClient { $message["username"] = $username; $message["passcode"] = $passcode; - msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err); - echo "message sent\n"; + msg_send($sr_queue, MSG_AUTH_USER_TOKEN, $message, true, true, $msg_err); + + msg_receive($cl_queue, 0, $msg_type, 16384, $msg); + + return $msg; + } + + function deleteUserToken($username) { + + global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) { + return false; + } + + if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) { + return false; + } + + // TODO we need to setup a client queue sem lock here + + $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT); + $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER); + + + $message["username"] = $username; + + msg_send($sr_queue, MSG_DELETE_USER_TOKEN, $message, true, true, $msg_err); msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); return $msg; } - function addUser($username) { + function addUser($username, $tokentype="", $hexkey="") { global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; @@ -193,19 +355,17 @@ class GAAuthClient { $message["username"] = $username; + if($tokentype!="") $message["tokentype"] = $tokentype; + if($hexkey!="") $message["hexkey"] = $hexkey; msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err); - echo "message sent\n"; msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); return $msg; - } - function setTokenType($username, $tokentype) { + function setUserTokenType($username, $tokentype) { global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT; @@ -227,16 +387,13 @@ class GAAuthClient { $message["username"] = $username; $message["tokentype"] = $tokentype; - msg_send($sr_queue, MSG_ADD_USER, $message, true, true, $msg_err); - echo "message sent\n"; + msg_send($sr_queue, MSG_SET_USER_TOKEN_TYPE, $message, true, true, $msg_err); msg_receive($cl_queue, 0, $msg_type, 16384, $msg); - echo "message received?\n"; - print_r($msg); return $msg; } } -?> \ No newline at end of file +?>