3 require_once("lib.php");
6 function addRadiusClient($clientname, $clientip, $clientsecret, $clientdesc) {
7 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
10 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
14 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
17 // TODO we need to setup a client queue sem lock here
19 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
20 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
23 $message["clientname"] = $clientname;
24 $message["clientsecret"] = $clientsecret;
25 $message["clientip"] = $clientip;
26 $message["clientdescription"] = $clientdesc;
28 msg_send($sr_queue, MSG_ADD_RADIUS_CLIENT, $message, true, true, $msg_err);
30 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
34 function syncUserToken($username, $tokenone, $tokentwo) {
35 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
38 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
42 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
45 // TODO we need to setup a client queue sem lock here
47 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
48 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
50 $message["username"] = $username;
51 $message["tokenone"] = $tokenone;
52 $message["tokentwo"] = $tokentwo;
54 msg_send($sr_queue, MSG_SYNC_TOKEN, $message, true, true, $msg_err);
56 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
60 function getUserTokenType($username) {
61 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
64 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
68 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
71 // TODO we need to setup a client queue sem lock here
73 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
74 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
76 $message["username"] = $username;
77 msg_send($sr_queue, MSG_GET_TOKEN_TYPE, $message, true, true, $msg_err);
79 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
83 function setUserToken($username, $token) {
84 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
87 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
91 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
94 // TODO we need to setup a client queue sem lock here
96 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
97 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
99 $message["username"] = $username;
100 $message["tokenstring"] = $token;
102 msg_send($sr_queue, MSG_SET_USER_TOKEN, $message, true, true, $msg_err);
104 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
108 function setUserPass($username, $password) {
109 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
112 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
116 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
119 // TODO we need to setup a client queue sem lock here
121 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
122 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
124 $message["username"] = $username;
125 $message["password"] = $password;
127 msg_send($sr_queue, MSG_SET_USER_PASSWORD, $message, true, true, $msg_err);
129 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
134 function getOtkID($username) {
135 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
138 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
142 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
145 // TODO we need to setup a client queue sem lock here
147 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
148 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
150 $message["username"] = $username;
151 msg_send($sr_queue, MSG_GET_OTK_ID, $message, true, true, $msg_err);
153 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
159 function getOtkPng($username, $otk) {
160 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
163 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
167 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
170 // TODO we need to setup a client queue sem lock here
172 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
173 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
175 $message["otk"] = $otk;
176 $message["username"] = $username;
177 error_log("sending message, $otk");
178 msg_send($sr_queue, MSG_GET_OTK_PNG, $message, true, true, $msg_err);
180 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
186 function authUserPass($username, $password) {
187 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
190 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
194 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
197 // TODO we need to setup a client queue sem lock here
199 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
200 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
202 $message["username"] = $username;
203 $message["password"] = $password;
205 msg_send($sr_queue, MSG_AUTH_USER_PASSWORD, $message, true, true, $msg_err);
207 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
211 function deleteUser($username) {
212 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
215 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
219 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
222 // TODO we need to setup a client queue sem lock here
224 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
225 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
227 $message["username"] = $username;
229 msg_send($sr_queue, MSG_DELETE_USER, $message, true, true, $msg_err);
231 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
237 function setUserRealName($username, $realname) {
238 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
241 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
245 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
248 // TODO we need to setup a client queue sem lock here
250 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
251 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
253 $message["username"] = $username;
254 $message["realname"] = $realname;
256 msg_send($sr_queue, MSG_SET_USER_REALNAME, $message, true, true, $msg_err);
258 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
262 function getUsers() {
263 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
266 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
270 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
273 // TODO we need to setup a client queue sem lock here
275 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
276 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
278 msg_send($sr_queue, MSG_GET_USERS, "", true, true, $msg_err);
280 msg_receive($cl_queue, 0, $msg_type, 524288, $msg);
285 function authUserToken($username, $passcode) {
286 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
289 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
293 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
296 // TODO we need to setup a client queue sem lock here
298 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
299 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
302 $message["username"] = $username;
303 $message["passcode"] = $passcode;
305 msg_send($sr_queue, MSG_AUTH_USER_TOKEN, $message, true, true, $msg_err);
307 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
312 function deleteUserToken($username) {
314 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
316 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
320 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
324 // TODO we need to setup a client queue sem lock here
326 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
327 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
330 $message["username"] = $username;
332 msg_send($sr_queue, MSG_DELETE_USER_TOKEN, $message, true, true, $msg_err);
334 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
339 function addUser($username, $tokentype="", $hexkey="") {
340 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
343 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
347 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
351 // TODO we need to setup a client queue sem lock here
353 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
354 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
357 $message["username"] = $username;
358 if($tokentype!="") $message["tokentype"] = $tokentype;
359 if($hexkey!="") $message["hexkey"] = $hexkey;
361 msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err);
363 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
368 function setUserTokenType($username, $tokentype) {
369 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
372 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
376 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
380 // TODO we need to setup a client queue sem lock here
382 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
383 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
387 $message["username"] = $username;
388 $message["tokentype"] = $tokentype;
390 msg_send($sr_queue, MSG_SET_USER_TOKEN_TYPE, $message, true, true, $msg_err);
392 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);