reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
RADIUSDigestAuthenticator.hxx
Go to the documentation of this file.
1
2#ifndef __RADIUSDigestAuthenticator_h
3#define __RADIUSDigestAuthenticator_h
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include "compat.hxx"
10
11#ifdef USE_RADIUS_CLIENT
12
13#ifdef RESIP_HAVE_RADCLI
14#include <radcli/radcli.h>
15typedef uint32_t UINT4;
16#else
17#ifdef RESIP_HAVE_FREERADIUS_CLIENT
18#include <freeradius-client.h>
19typedef uint32_t UINT4;
20#else
21#include <radiusclient-ng.h>
22#endif
23#endif
24
25#include "rutil/Data.hxx"
26#include "rutil/ThreadIf.hxx"
27
28#define RADIUS_CONFIG "/etc/radiusclient/radiusclient.conf"
29#define RADIUS_MSG_SIZE 4096
30#define RADIUS_SIP_PORT 5060
31
32/*
33
34 Class for performing RADIUS authentication of SIP users
35
36 Based largely on the auth_radius module in SER - http://iptel.org/ser
37
38 Permission has been given by Jan Janak, the author of auth_radius, for
39 this code to be redistributed under a BSD-like license.
40
41 see http://www.iptel.org/ietf/aaa/draft-schulzrinne-sipping-radius-accounting-00.txt */
42
43/*
44 * WARNING: Don't forget to update the dictionary if you update this file !!!
45 */
46
47namespace resip
48{
49
50struct attr
51{
52 const char *n;
53 int v;
54};
55
56struct val
57{
58 const char *n;
59 int v;
60};
61
62#define A_USER_NAME 0
63#define A_SERVICE_TYPE 1
64#define A_CALLED_STATION_ID 2
65#define A_CALLING_STATION_ID 3
66#define A_ACCT_STATUS_TYPE 4
67#define A_ACCT_SESSION_ID 5
68#define A_SIP_METHOD 6
69#define A_SIP_RESPONSE_CODE 7
70#define A_SIP_CSEQ 8
71#define A_SIP_TO_TAG 9
72#define A_SIP_FROM_TAG 10
73#define A_SIP_TRANSLATED_REQUEST_URI 11
74#define A_DIGEST_RESPONSE 12
75#define A_DIGEST_ATTRIBUTES 13
76#define A_SIP_URI_USER 14
77#define A_SIP_RPID 15
78#define A_DIGEST_REALM 16
79#define A_DIGEST_NONCE 17
80#define A_DIGEST_METHOD 18
81#define A_DIGEST_URI 19
82#define A_DIGEST_QOP 20
83#define A_DIGEST_ALGORITHM 21
84#define A_DIGEST_BODY_DIGEST 22
85#define A_DIGEST_CNONCE 23
86#define A_DIGEST_NONCE_COUNT 24
87#define A_DIGEST_USER_NAME 25
88#define A_SIP_GROUP 26
89#define A_CISCO_AVPAIR 27
90#define A_VM_EMAIL 28
91#define A_VM_LANGUAGE 29
92#define A_MAX 30
93
94#define V_STATUS_START 0
95#define V_STATUS_STOP 1
96#define V_STATUS_FAILED 2
97#define V_CALL_CHECK 3
98#define V_EMERGENCY_CALL 4
99#define V_SIP_SESSION 5
100#define V_GROUP_CHECK 6
101#define V_VM_INFO 7
102#define V_MAX 8
103
104
105// An instance of this class is notified when the RADIUSDigestAuthenticator
106// has done it's work
108{
109 public:
110 virtual ~RADIUSDigestAuthListener();
111 // These methods will be called from a separate thread of execution
112 virtual void onSuccess(const resip::Data& rpid) = 0;
113 virtual void onAccessDenied() = 0;
114 virtual void onError() = 0;
115};
116
118{
119 public:
120 TestRADIUSDigestAuthListener();
121 void onSuccess(const resip::Data& rpid);
122 void onAccessDenied();
123 void onError();
124};
125
126// An instance of this class will attempt to authenticate the request
127// using RADIUS
129 //class RADIUSDigestAuthenticator : public ost::Thread {
130
131 private:
132
133 resip::Data username; // username from ProxyAuth header
134 resip::Data digestUsername; // username from digest header
135 resip::Data digestRealm; // realm from digest header
136 resip::Data digestNonce; // nonce from digest header
137 resip::Data digestUri; // request URI from request line
138 resip::Data digestMethod; // request method (e.g. INVITE)
139 resip::Data digestQop; // QoP is one of "", "auth", "auth-int"
140 resip::Data digestNonceCount; // nonce count or ""
141 resip::Data digestCNonce; // cnonce or ""
142 resip::Data digestBodyDigest; // value of opaque or ""
143 resip::Data digestResponse; // digest string submitted by client
144
145 RADIUSDigestAuthListener *listener;
146
147 public:
148
149 static void init(const char *radiusConfigFile);
150
151 // No QoP
152 RADIUSDigestAuthenticator(const resip::Data& username,
153 const resip::Data& digestUsername,
154 const resip::Data& digestRealm,
155 const resip::Data& digestNonce,
156 const resip::Data& digestUri,
157 const resip::Data& digestMethod,
158 const resip::Data& digestResponse,
159 RADIUSDigestAuthListener *listener);
160
161 // QoP auth
162 RADIUSDigestAuthenticator(const resip::Data& username,
163 const resip::Data& digestUsername,
164 const resip::Data& digestRealm,
165 const resip::Data& digestNonce,
166 const resip::Data& digestUri,
167 const resip::Data& digestMethod,
168 const resip::Data& digestQop,
169 const resip::Data& digestNonceCount,
170 const resip::Data& digestCNonce,
171 const resip::Data& digestResponse,
172 RADIUSDigestAuthListener *listener);
173
174 // QoP auth-int
175 RADIUSDigestAuthenticator(const resip::Data& username,
176 const resip::Data& digestUsername,
177 const resip::Data& digestRealm,
178 const resip::Data& digestNonce,
179 const resip::Data& digestUri,
180 const resip::Data& digestMethod,
181 const resip::Data& digestQop,
182 const resip::Data& digestNonceCount,
183 const resip::Data& digestCNonce,
184 const resip::Data& digestBodyDigest,
185 const resip::Data& digestResponse,
186 RADIUSDigestAuthListener *listener);
187
188 virtual ~RADIUSDigestAuthenticator();
189
190 int doRADIUSCheck();
191
192 protected:
193
194 static struct attr *attrs;
195 static struct val *vals;
196 static rc_handle *rh;
197
198 void thread();
199 void final();
200
202
203};
204
205
206}
207
208#endif
209
210#endif
211
212
213/* ====================================================================
214 *
215 * Copyright 2012 Daniel Pocock. All rights reserved.
216 *
217 * Redistribution and use in source and binary forms, with or without
218 * modification, are permitted provided that the following conditions
219 * are met:
220 *
221 * 1. Redistributions of source code must retain the above copyright
222 * notice, this list of conditions and the following disclaimer.
223 *
224 * 2. Redistributions in binary form must reproduce the above copyright
225 * notice, this list of conditions and the following disclaimer in
226 * the documentation and/or other materials provided with the
227 * distribution.
228 *
229 * 3. Neither the name of the author(s) nor the names of any contributors
230 * may be used to endorse or promote products derived from this software
231 * without specific prior written permission.
232 *
233 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) AND CONTRIBUTORS "AS IS" AND
234 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
235 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTORS BE LIABLE
237 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
238 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
239 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
240 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
243 * SUCH DAMAGE.
244 *
245 * ====================================================================
246 *
247 *
248 */
249
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
A wrapper class to create and spawn a thread.
Definition ThreadIf.hxx:54
This file is used to handle compatibility fixes/tweaks so reSIProcate can function on multiple platfo...
dcm! – add UnusedChecking(_enum) below;
unsigned int uint32_t
Definition stdint.h:85
void list()
Definition userAdmin.cxx:66