]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libstrongswan/plugins/acert/acert_plugin.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libstrongswan / plugins / acert / acert_plugin.c
1 /*
2 * Copyright (C) 2014 Martin Willi
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17 #include "acert_plugin.h"
18 #include "acert_validator.h"
19
20 #include <library.h>
21
22 typedef struct private_acert_plugin_t private_acert_plugin_t;
23
24 /**
25 * private data of acert_plugin
26 */
27 struct private_acert_plugin_t {
28
29 /**
30 * public functions
31 */
32 acert_plugin_t public;
33
34 /**
35 * Validator implementation instance.
36 */
37 acert_validator_t *validator;
38 };
39
40 METHOD(plugin_t, get_name, char*,
41 private_acert_plugin_t *this)
42 {
43 return "acert";
44 }
45
46 /**
47 * Register validator
48 */
49 static bool plugin_cb(private_acert_plugin_t *this,
50 plugin_feature_t *feature, bool reg, void *cb_data)
51 {
52 if (reg)
53 {
54 lib->credmgr->add_validator(lib->credmgr, &this->validator->validator);
55 }
56 else
57 {
58 lib->credmgr->remove_validator(lib->credmgr, &this->validator->validator);
59 }
60 return TRUE;
61 }
62
63 METHOD(plugin_t, get_features, int,
64 private_acert_plugin_t *this, plugin_feature_t *features[])
65 {
66 static plugin_feature_t f[] = {
67 PLUGIN_CALLBACK((plugin_feature_callback_t)plugin_cb, NULL),
68 PLUGIN_PROVIDE(CUSTOM, "acert"),
69 };
70 *features = f;
71 return countof(f);
72 }
73
74 METHOD(plugin_t, destroy, void,
75 private_acert_plugin_t *this)
76 {
77 this->validator->destroy(this->validator);
78 free(this);
79 }
80
81 /*
82 * see header file
83 */
84 plugin_t *acert_plugin_create()
85 {
86 private_acert_plugin_t *this;
87
88 INIT(this,
89 .public = {
90 .plugin = {
91 .get_name = _get_name,
92 .get_features = _get_features,
93 .destroy = _destroy,
94 },
95 },
96 .validator = acert_validator_create(),
97 );
98
99 return &this->public.plugin;
100 }