Added possibility to send notifications from the Quick Mode task
[strongswan.git] / src / libcharon / plugins / xauth_null / xauth_null.c
1 /*
2 * Copyright (C) 2007-2008 Martin Willi
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 "xauth_null.h"
17
18 #include <daemon.h>
19 #include <library.h>
20
21 typedef struct private_xauth_null_t private_xauth_null_t;
22
23 /**
24 * Private data of an xauth_null_t object.
25 */
26 struct private_xauth_null_t {
27
28 /**
29 * Public authenticator_t interface.
30 */
31 xauth_null_t public;
32 };
33
34 METHOD(xauth_method_t, process_peer, status_t,
35 private_xauth_null_t *this, cp_payload_t *in, cp_payload_t **out)
36 {
37 chunk_t user_name = chunk_from_chars('t', 'e', 's', 't');
38 chunk_t user_pass = chunk_from_chars('t', 'e', 's', 't');
39 cp_payload_t *cp;
40
41 cp = cp_payload_create_type(CONFIGURATION_V1, CFG_REPLY);
42 cp->add_attribute(cp, configuration_attribute_create_chunk(
43 CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_NAME, user_name));
44 cp->add_attribute(cp, configuration_attribute_create_chunk(
45 CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_PASSWORD, user_pass));
46 *out = cp;
47 return NEED_MORE;
48 }
49
50 METHOD(xauth_method_t, initiate_peer, status_t,
51 private_xauth_null_t *this, cp_payload_t **out)
52 {
53 /* peer never initiates */
54 return FAILED;
55 }
56
57 METHOD(xauth_method_t, process_server, status_t,
58 private_xauth_null_t *this, cp_payload_t *in, cp_payload_t **out)
59 {
60 /* always successful */
61 return SUCCESS;
62 }
63
64 METHOD(xauth_method_t, initiate_server, status_t,
65 private_xauth_null_t *this, cp_payload_t **out)
66 {
67 cp_payload_t *cp;
68
69 cp = cp_payload_create_type(CONFIGURATION_V1, CFG_REQUEST);
70 cp->add_attribute(cp, configuration_attribute_create_chunk(
71 CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_NAME, chunk_empty));
72 cp->add_attribute(cp, configuration_attribute_create_chunk(
73 CONFIGURATION_ATTRIBUTE_V1, XAUTH_USER_PASSWORD, chunk_empty));
74
75 *out = cp;
76 return NEED_MORE;
77 }
78
79 METHOD(xauth_method_t, destroy, void,
80 private_xauth_null_t *this)
81 {
82 free(this);
83 }
84
85 /*
86 * Described in header.
87 */
88 xauth_null_t *xauth_null_create_peer(identification_t *server,
89 identification_t *peer)
90 {
91 private_xauth_null_t *this;
92
93 INIT(this,
94 .public = {
95 .xauth_method = {
96 .initiate = _initiate_peer,
97 .process = _process_peer,
98 .destroy = _destroy,
99 },
100 },
101 );
102
103 return &this->public;
104 }
105
106 /*
107 * Described in header.
108 */
109 xauth_null_t *xauth_null_create_server(identification_t *server,
110 identification_t *peer)
111 {
112 private_xauth_null_t *this;
113
114 INIT(this,
115 .public = {
116 .xauth_method = {
117 .initiate = _initiate_server,
118 .process = _process_server,
119 .destroy = _destroy,
120 },
121 },
122 );
123
124 return &this->public;
125 }