diff --git a/include/auth/auth.h b/include/auth/auth.h
index 2518918..b8e308e 100644
--- a/include/auth/auth.h
+++ b/include/auth/auth.h
@@ -1,5 +1,20 @@
/**
* \file
+ * Container for authentication modules.
+ *
+ * This is a single point of authentication no matter how much
+ * authentication modules are in place. Thus it prevents adding
+ * more and more authentication modules to the application.
+ * This is an auth module itself but this one returns 0 if
+ * the authentication has failed otherwise the id of the
+ * successfull auth module. Thus we can identify by what method
+ * the user has been authenticated.
+ *
+ * This can't authenticate by its own. It has to be initialized
+ * with other auth modules by calling authCreate at least once.
+ *
+ * origin intend ... never implemented (but maybe a good idea)
+ *
* Authenticatio module factory
*
* A factory to get a specific authentication module.
@@ -28,17 +43,23 @@
#define __AUTH_AUTH_H__
#include "class.h"
-#include "auth/ldap.h"
+#include "uuid.h"
+#include "auth.h"
+#include "auth/credential.h"
+
typedef enum e_AuthModule {
- AUTH_LDAP = 0
+ AUTH_LDAP = 1,
+ AUTH_STORAGE = 2
} AuthModule;
+#define MAX_AUTH AUTH_STORAGE
+
CLASS(Auth) {
+ void * auth[MAX_AUTH + 1];
};
-void * authCreateById(Auth, int);
-AuthLdap authCreateLdap(Auth);
+int authCreate(Auth, AuthModule, ...);
#endif // __AUTH_AUTH_H__
diff --git a/src/auth/Makefile.am b/src/auth/Makefile.am
index 52b1612..0667b23 100644
--- a/src/auth/Makefile.am
+++ b/src/auth/Makefile.am
@@ -3,6 +3,8 @@ AUTOMAKE_OPTIONS = subdir-objects
AUTH = interface/auth.c \
credential.c \
+ auth.c \
+ create.c \
ldap.c \
storage/storage.c \
storage/hash_pw.c
diff --git a/src/auth/auth.c b/src/auth/auth.c
new file mode 100644
index 0000000..9775269
--- /dev/null
+++ b/src/auth/auth.c
@@ -0,0 +1,84 @@
+/**
+ * \file
+ *
+ * \author Georg Hopp
+ *
+ * \copyright
+ * Copyright © 2013 Georg Hopp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include "class.h"
+#include "uuid.h"
+#include "utils/memory.h"
+#include "commons.h"
+
+#include "auth.h"
+#include "auth/credential.h"
+#include "auth/interface/auth.h"
+
+static
+int
+authCtor(void * _this, va_list * params)
+{
+ Auth this = _this;
+ int i;
+
+ for (i=0; i<=MAX_AUTH; i++) {
+ this->auth[i] = NULL;
+ }
+
+ return 0;
+}
+
+static
+void
+authDtor(void * _this)
+{
+ Auth this = _this;
+ int i;
+
+ for (i=1; i<=MAX_AUTH; i++) {
+ delete(this->auth[i]);
+ }
+}
+
+static
+int
+authAuthenticate(void * _this, Credential cred, Uuid user_index)
+{
+ Auth this = _this;
+ int i;
+
+ for (i=1; i<=MAX_AUTH; i++) {
+ if (authenticate(this->auth[i], cred, user_index)) {
+ return i;
+ }
+ }
+
+ return FALSE;
+}
+
+INIT_IFACE(Class, authCtor, authDtor, NULL);
+INIT_IFACE(Auth, authAuthenticate);
+CREATE_CLASS(Auth, NULL, IFACE(Class), IFACE(Auth));
+
+// vim: set ts=4 sw=4:
diff --git a/src/auth/create.c b/src/auth/create.c
new file mode 100644
index 0000000..e5923ef
--- /dev/null
+++ b/src/auth/create.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ *
+ * \author Georg Hopp
+ *
+ * \copyright
+ * Copyright © 2013 Georg Hopp
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include
+
+#include "class.h"
+#include "auth.h"
+#include "auth/ldap.h"
+#include "auth/storage.h"
+#include "commons.h"
+
+int
+authCreate(Auth this, AuthModule module, ...)
+{
+ va_list params;
+
+ if (NULL != this->auth[module]) {
+ delete(this->auth[module]);
+ }
+
+ va_start(params, module);
+
+ switch (module) {
+ case AUTH_LDAP:
+ this->auth[module] = newParams(AuthLdap, ¶ms);
+ break;
+
+ case AUTH_STORAGE:
+ this->auth[module] = newParams(AuthStorage, ¶ms);
+ break;
+ }
+
+ va_end(params);
+
+ if (NULL == this->auth[module]) {
+ return FALSE;
+ }
+
+ return module;
+}
+
+// vim: set ts=4 sw=4: