taskrambler  0.1.9
Web server and task management solution.
auth.c
Go to the documentation of this file.
1 /**
2  * \file
3  *
4  * \author Georg Hopp
5  *
6  * \copyright
7  * Copyright © 2013 Georg Hopp
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include <stdarg.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <stdio.h>
27 #include <ldap.h>
28 
29 #include "class.h"
30 #include "uuid.h"
31 #include "utils/memory.h"
32 #include "commons.h"
33 
34 #include "auth.h"
35 #include "auth/credential.h"
36 #include "auth/interface/auth.h"
37 
38 static
39 int
40 authCtor(void * _this, va_list * params)
41 {
42  Auth this = _this;
43  int i;
44 
45  for (i=0; i<=MAX_AUTH; i++) {
46  this->auth[i] = NULL;
47  }
48 
49  return 0;
50 }
51 
52 static
53 void
54 authDtor(void * _this)
55 {
56  Auth this = _this;
57  int i;
58 
59  for (i=1; i<=MAX_AUTH; i++) {
60  delete(this->auth[i]);
61  }
62 }
63 
64 static
65 int
66 authAuthenticate(void * _this, Credential cred, Uuid user_index)
67 {
68  Auth this = _this;
69  int i;
70 
71  for (i=1; i<=MAX_AUTH; i++) {
72  if (authenticate(this->auth[i], cred, user_index)) {
73  return i;
74  }
75  }
76 
77  return FALSE;
78 }
79 
80 INIT_IFACE(Class, authCtor, authDtor, NULL);
82 CREATE_CLASS(Auth, NULL, IFACE(Class), IFACE(Auth));
83 
84 // vim: set ts=4 sw=4:
static void authDtor(void *_this)
Definition: auth.c:54
#define MAX_AUTH
Definition: auth/auth.h:56
static int authCtor(void *_this, va_list *params)
Definition: auth.c:40
int authenticate(void *, Credential, Uuid)
#define IFACE(name)
Definition: interface.h:34
static int authAuthenticate(void *_this, Credential cred, Uuid user_index)
Definition: auth.c:66
#define FALSE
Definition: commons.h:28
INIT_IFACE(Class, authCtor, authDtor, NULL)
CREATE_CLASS(Auth, NULL, IFACE(Class), IFACE(Auth))