more authserver code
[ga4php.git] / authserver / lib / authClient.php
1 <?php
2
3 require_once("lib.php");
4
5 class GAAuthClient {
6         
7         function setUserToken($username, $token) {
8                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
9                 
10                 
11                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
12                         return false;
13                 }
14
15                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
16                         return false;
17                 }
18                 // TODO we need to setup a client queue sem lock here
19                 
20                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
21                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
22                 
23         }
24         
25         function setUserPass($username, $password) {
26                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
27                 
28                 
29                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
30                         return false;
31                 }
32
33                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
34                         return false;
35                 }
36                 // TODO we need to setup a client queue sem lock here
37                 
38                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
39                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
40                 
41         }
42         
43         function authUserPass($username, $password) {
44                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
45                 
46                 
47                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
48                         return false;
49                 }
50
51                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
52                         return false;
53                 }
54                 // TODO we need to setup a client queue sem lock here
55                 
56                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
57                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
58                 
59         }
60         
61         function deleteUser($username) {
62                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
63                 
64                 
65                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
66                         return false;
67                 }
68
69                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
70                         return false;
71                 }
72                 // TODO we need to setup a client queue sem lock here
73                 
74                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
75                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
76                 
77         }
78         
79         function setUserRealName($username, $realname) {
80                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
81                 
82                 
83                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
84                         return false;
85                 }
86
87                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
88                         return false;
89                 }
90                 // TODO we need to setup a client queue sem lock here
91                 
92                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
93                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
94                 
95         }
96         
97         function authUserToken($username, $passcode) {
98                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
99                 
100                 
101                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
102                         return false;
103                 }
104
105                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
106                         return false;
107                 }
108                 // TODO we need to setup a client queue sem lock here
109                 
110                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
111                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
112                 
113                 
114                 $message["user"] = $username;
115                 $message["passcode"] = $passcode;
116                 
117                 msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err);
118                 echo "message sent\n";
119                 
120                 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
121                 echo "message received?\n";
122                 print_r($msg);
123                 
124                 return $msg;
125         }
126         
127         function addUser($username) {
128                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
129                 
130                 
131                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
132                         return false;
133                 }
134
135                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
136                         return false;
137                 }
138                 
139                 // TODO we need to setup a client queue sem lock here
140                 
141                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
142                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
143                 
144                 
145                 $message["username"] = $username;
146                 
147                 msg_send($sr_queue, MSG_ADD_USER, $message, true, true, $msg_err);
148                 echo "message sent\n";
149                 
150                 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
151                 echo "message received?\n";
152                 print_r($msg);
153                 
154                 return $msg;
155                 
156         }
157
158         function setTokenType($username, $tokentype) {
159                 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
160                 
161                 
162                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
163                         return false;
164                 }
165
166                 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
167                         return false;
168                 }
169                 
170                 // TODO we need to setup a client queue sem lock here
171                 
172                 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
173                 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
174                 
175                 
176                 $message["username"] = $username;
177                 
178                 
179         }
180 }
181
182 ?>