diff options
author | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
---|---|---|
committer | Yves-Alexis Perez <corsac@corsac.net> | 2012-06-28 21:16:07 +0200 |
commit | b34738ed08c2227300d554b139e2495ca5da97d6 (patch) | |
tree | 62f33b52820f2e49f0e53c0f8c636312037c8054 /src/medsrv/filter | |
parent | 0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff) | |
download | vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip |
Imported Upstream version 4.6.4
Diffstat (limited to 'src/medsrv/filter')
-rwxr-xr-x | src/medsrv/filter/auth_filter.c | 137 | ||||
-rwxr-xr-x | src/medsrv/filter/auth_filter.h | 90 |
2 files changed, 114 insertions, 113 deletions
diff --git a/src/medsrv/filter/auth_filter.c b/src/medsrv/filter/auth_filter.c index 9ed356042..d21abdc46 100755 --- a/src/medsrv/filter/auth_filter.c +++ b/src/medsrv/filter/auth_filter.c @@ -1,50 +1,48 @@ /* - * Copyright (C) 2008 Martin Willi
- * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
- * Hochschule fuer Technik Rapperswil
- *
- * 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 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * 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.
- */
-
-#include "auth_filter.h"
-
-#include <debug.h>
-
-typedef struct private_auth_filter_t private_auth_filter_t;
-
-/**
- * private data of auth_filter
- */
-struct private_auth_filter_t {
- /**
- * public functions
- */
- auth_filter_t public;
-
- /**
- * user session
- */
+ * Copyright (C) 2008 Martin Willi + * Copyright (C) 2008 Philip Boetschi, Adrian Doerig + * Hochschule fuer Technik Rapperswil + * + * 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 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * 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. + */ + +#include "auth_filter.h" + +#include <debug.h> + +typedef struct private_auth_filter_t private_auth_filter_t; + +/** + * private data of auth_filter + */ +struct private_auth_filter_t { + /** + * public functions + */ + auth_filter_t public; + + /** + * user session + */ user_t *user; /** * database connection */ - database_t *db;
+ database_t *db; }; -
-/**
- * Implementation of filter_t.run
- */
-static bool run(private_auth_filter_t *this, request_t *request, - char *controller, char *action)
+ +METHOD(filter_t, run, bool, + private_auth_filter_t *this, request_t *request, char *controller, + char *action, char *p2, char *p3, char *p4, char *p5) { if (this->user->get_user(this->user)) { @@ -67,32 +65,35 @@ static bool run(private_auth_filter_t *this, request_t *request, (streq(action, "add") || streq(action, "login") || streq(action, "help"))) { /* add/login allowed */ return TRUE; - }
- request->redirect(request, "user/login");
- return FALSE;
-}
-
-/**
- * Implementation of filter_t.destroy
- */
-static void destroy(private_auth_filter_t *this)
-{
- free(this);
-}
-
-/*
- * see header file
- */
-filter_t *auth_filter_create(user_t *user, database_t *db)
-{
- private_auth_filter_t *this= malloc_thing(private_auth_filter_t);
-
- this->public.filter.destroy = (void(*)(filter_t*))destroy;
- this->public.filter.run = (bool(*)(filter_t*, request_t*,char*,char*,char*,char*,char*,char*))run;
-
- this->user = user; - this->db = db;
-
- return &this->public.filter;
-}
+ } + request->redirect(request, "user/login"); + return FALSE; +} + +METHOD(filter_t, destroy, void, + private_auth_filter_t *this) +{ + free(this); +} + +/* + * see header file + */ +filter_t *auth_filter_create(user_t *user, database_t *db) +{ + private_auth_filter_t *this; + + INIT(this, + .public = { + .filter = { + .destroy = _destroy, + .run = _run, + }, + }, + .user = user, + .db = db, + ); + + return &this->public.filter; +} diff --git a/src/medsrv/filter/auth_filter.h b/src/medsrv/filter/auth_filter.h index f1fc565eb..c46de40a5 100755 --- a/src/medsrv/filter/auth_filter.h +++ b/src/medsrv/filter/auth_filter.h @@ -1,48 +1,48 @@ /* - * Copyright (C) 2008 Martin Willi
- * Copyright (C) 2008 Philip Boetschi, Adrian Doerig
- * Hochschule fuer Technik Rapperswil
- *
- * 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 2 of the License, or (at your
- * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * 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.
- */
-
-/**
- * @defgroup auth_filter_server auth_filter
- * @{ @ingroup filter_server
- */
-
-#ifndef AUTH_FILTER_H_
-#define AUTH_FILTER_H_
-
-#include <library.h>
+ * Copyright (C) 2008 Martin Willi + * Copyright (C) 2008 Philip Boetschi, Adrian Doerig + * Hochschule fuer Technik Rapperswil + * + * 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 2 of the License, or (at your + * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. + * + * 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. + */ + +/** + * @defgroup auth_filter_server auth_filter + * @{ @ingroup filter_server + */ + +#ifndef AUTH_FILTER_H_ +#define AUTH_FILTER_H_ + +#include <library.h> #include <filter.h> -#include "user.h"
-
-typedef struct auth_filter_t auth_filter_t;
-
-/**
- * Authentication/Authorization filter.
- */
-struct auth_filter_t {
-
- /**
- * Implements filter_t interface.
- */
- filter_t filter;
-};
-
-/**
- * Create a auth_filter instance.
- */
-filter_t *auth_filter_create(user_t *user, database_t *db);
-
-#endif /* AUTH_FILTER_H_ @}*/
+#include "user.h" + +typedef struct auth_filter_t auth_filter_t; + +/** + * Authentication/Authorization filter. + */ +struct auth_filter_t { + + /** + * Implements filter_t interface. + */ + filter_t filter; +}; + +/** + * Create a auth_filter instance. + */ +filter_t *auth_filter_create(user_t *user, database_t *db); + +#endif /* AUTH_FILTER_H_ @}*/ |