implemented xauth as a pluto plugin
[strongswan.git] / src / pluto / plugins / xauth / xauth_default_provider.c
1 /*
2 * Copyright (C) 2010 Andreas Steffen
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include <keys.h>
17
18 #include "xauth_default_provider.h"
19
20 typedef struct private_xauth_default_provider_t private_xauth_default_provider_t;
21
22 /**
23 * private data of xauth_default_provider
24 */
25 struct private_xauth_default_provider_t {
26
27 /**
28 * public functions
29 */
30 xauth_provider_t public;
31 };
32
33 METHOD(xauth_provider_t, get_secret, bool,
34 private_xauth_default_provider_t *this, connection_t *c, chunk_t *secret)
35 {
36 identification_t *user, *server;
37
38 server = c->spd.that.id;
39 user = (c->xauth_identity) ? c->xauth_identity : c->spd.this.id;
40
41 return get_xauth_secret(user, server, secret);
42 }
43
44 METHOD(xauth_provider_t, destroy, void,
45 private_xauth_default_provider_t *this)
46 {
47 free(this);
48 }
49
50 /*
51 * Described in header.
52 */
53 xauth_provider_t *xauth_default_provider_create()
54 {
55 private_xauth_default_provider_t *this;
56
57 INIT(this,
58 .public = {
59 .get_secret = _get_secret,
60 .destroy = _destroy,
61 }
62 );
63
64 return &this->public;
65 }
66