fixed a minor thing with the hotp skew
[ga4php.git] / authserver / lib / authClient.php
index a3a2172..677be24 100644 (file)
@@ -144,6 +144,32 @@ class GAAuthClient {
                
        }
        
+       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);
+               echo "message sent\n";
+               
+               msg_receive($cl_queue, 0, $msg_type, 524288, $msg);
+               echo "message received?\n";
+               print_r($msg);
+               
+               return $msg;
+       }
+       
        function authUserToken($username, $passcode) {
                global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
                
@@ -164,17 +190,15 @@ class GAAuthClient {
                $message["username"] = $username;
                $message["passcode"] = $passcode;
                
-               msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err);
+               msg_send($sr_queue, MSG_AUTH_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 addUser($username) {
+       function addUser($username, $tokentype="", $hexkey="") {
                global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
                
                
@@ -193,16 +217,14 @@ 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) {
@@ -239,4 +261,4 @@ class GAAuthClient {
        }
 }
 
-?>
\ No newline at end of file
+?>