reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
WebAdmin.hxx
Go to the documentation of this file.
1#if !defined(RESIP_WEBADMIN_HXX)
2#define RESIP_WEBADMIN_HXX
3
4#include "rutil/Data.hxx"
5#include "rutil/Condition.hxx"
10#include "repro/HttpBase.hxx"
11
12#include <map>
13#include <memory>
14
15namespace resip
16{
17class RegistrationPersistenceManager;
18class PublicationPersistenceManager;
19class Security;
20class DataStream;
21}
22
23
24namespace repro
25{
26class Store;
27class UserStore;
28class RouteStore;
29class RestAdmin;
30typedef std::map<resip::Data, resip::Data> Dictionary;
31class Proxy;
32
33class WebAdmin : public HttpBase,
35{
36 public:
38 {
39 public:
41 const resip::Data& file,
42 const int line)
43 : BaseException(msg, file, line) {}
44 protected:
45 const char* name() const noexcept override { return "WebAdmin::ConfigException"; }
46 };
47
51 const resip::Data& realm, // this realm is used for http challenges
52 int port=5080,
55
56 virtual ~WebAdmin();
57
58 // (Re)load the users.txt file
59 void parseUserFile();
60
61 // Called by ReproRunner (on the stack thread) when a StatisticsMessage
62 // is delivered. Populates the shared stats payload and signals any
63 // threads waiting in RestAdmin::handleStats for fresh data.
65
66 // Used by RestAdmin to send a JSON response on a pending connection.
67 // statusCode is the HTTP status (e.g. 200, 400, 404, 500).
68 void setApiResponse(int pageNumber, int statusCode, const resip::Data& jsonBody);
69
70 protected:
71 friend class CommandServer;
72 virtual void buildPage( const resip::Data& method,
73 const resip::Data& uri,
74 int pageNumber,
75 const resip::Data& user,
76 const resip::Data& password);
77
78 // Handler
79 virtual void onDnsCacheDumpRetrieved(std::pair<unsigned long, unsigned long> key, const resip::Data& dnsEntryStrings);
80
81 private:
82 resip::Data buildDefaultPage();
83 resip::Data buildUserPage();
84
85 void buildDomainsSubPage(resip::DataStream& s);
86 void buildAclsSubPage(resip::DataStream& s);
87
88 void buildAddUserSubPage(resip::DataStream& s);
89 void buildEditUserSubPage(resip::DataStream& s);
90 void buildShowUsersSubPage(resip::DataStream& s);
91
92 void buildAddFilterSubPage(resip::DataStream& s);
93 void buildEditFilterSubPage(resip::DataStream& s);
94 void buildShowFiltersSubPage(resip::DataStream& s);
95
96 void buildAddRouteSubPage(resip::DataStream& s);
97 void buildEditRouteSubPage(resip::DataStream& s);
98 void buildShowRoutesSubPage(resip::DataStream& s);
99
100 void buildRegistrationsSubPage(resip::DataStream& s);
101 void buildPublicationsSubPage(resip::DataStream& s);
102 void buildSettingsSubPage(resip::DataStream& s);
103 void buildRestartSubPage(resip::DataStream& s);
104 void buildLogLevelSubPage(resip::DataStream& s);
105 void buildReloadCertsSubPage(resip::DataStream& s);
106
107 resip::Data buildCertPage(const resip::Data& domain);
108
109 Proxy& mProxy;
110 Store& mStore;
113
114 resip::Data mDnsCache;
115 resip::Mutex mDnsCacheMutex;
116 resip::Condition mDnsCacheCondition;
117
118 // Statistics manager results delivered asynchronously via
119 // handleStatisticsMessage. mStatsReady is set to true by that handler
120 // once mStatsPayload is filled in; RestAdmin::handleStats waits on the
121 // condition with a timeout.
123 bool mStatsReady;
124 resip::Mutex mStatsMutex;
125 resip::Condition mStatsCondition;
126
127 bool mNoWebChallenges;
128
129 Dictionary mHttpParams;
130
131 // list of the keys of records that should be deleted
132 class RemoveKey
133 {
134 public:
135 RemoveKey(const resip::Data &key1, const resip::Data &key2);
136 bool operator<(const RemoveKey& rhs) const;
137 resip::Data mKey1;
138 resip::Data mKey2;
139 };
140 std::set<RemoveKey> mRemoveSet;
141
142 resip::Data mPageOutlinePre;
143 resip::Data mPageOutlinePost;
144
145 resip::Data mUserFile;
146 std::map<resip::Data,resip::Data> mUsers;
147
148 // REST API handler; constructed after other members are initialized.
149 // Given a unique_ptr so we can forward-declare RestAdmin.
150 std::unique_ptr<RestAdmin> mRestAdmin;
151
152 friend class RestAdmin;
153};
154
155
156
157}
158
159#endif
160
161/* ====================================================================
162 * The Vovida Software License, Version 1.0
163 *
164 * Copyright (c) 2026 SIP Spectrum, Inc. https://www.sipspectrum.com
165 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
166 *
167 * Redistribution and use in source and binary forms, with or without
168 * modification, are permitted provided that the following conditions
169 * are met:
170 *
171 * 1. Redistributions of source code must retain the above copyright
172 * notice, this list of conditions and the following disclaimer.
173 *
174 * 2. Redistributions in binary form must reproduce the above copyright
175 * notice, this list of conditions and the following disclaimer in
176 * the documentation and/or other materials provided with the
177 * distribution.
178 *
179 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
180 * and "Vovida Open Communication Application Library (VOCAL)" must
181 * not be used to endorse or promote products derived from this
182 * software without prior written permission. For written
183 * permission, please contact vocal@vovida.org.
184 *
185 * 4. Products derived from this software may not be called "VOCAL", nor
186 * may "VOCAL" appear in their name, without prior written
187 * permission of Vovida Networks, Inc.
188 *
189 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
190 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
192 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
193 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
194 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
195 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
196 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
197 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
198 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
199 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
200 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
201 * DAMAGE.
202 *
203 * ====================================================================
204 *
205 * This software consists of voluntary contributions made by Vovida
206 * Networks, Inc. and many individuals on behalf of Vovida Networks,
207 * Inc. For more information on Vovida Networks, Inc., please see
208 * <http://www.vovida.org/>.
209 *
210 */
The Store contains differnt types of stores such as user, route, etc.
Definition Store.hxx:21
ConfigException(const resip::Data &msg, const resip::Data &file, const int line)
Definition WebAdmin.hxx:40
const char * name() const noexcept override
Definition WebAdmin.hxx:45
virtual void handleStatisticsMessage(resip::StatisticsMessage &statsMessage)
virtual void onDnsCacheDumpRetrieved(std::pair< unsigned long, unsigned long > key, const resip::Data &dnsEntryStrings)
void parseUserFile()
Load web admin users from a file.
Definition WebAdmin.cxx:203
void setApiResponse(int pageNumber, int statusCode, const resip::Data &jsonBody)
virtual ~WebAdmin()
Definition WebAdmin.cxx:183
virtual void buildPage(const resip::Data &method, const resip::Data &uri, int pageNumber, const resip::Data &user, const resip::Data &password)
Definition WebAdmin.cxx:298
The abstract base-class for all exceptions thrown by resip code.
BaseException(const Data &msg, const Data &file, int line)
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
static const Data Empty
Constant that represents a zero-length data.
Definition Data.hxx:882
Abstract interface of a datastore of all publication documents processed by DUM.
Abstract interface of a datastore of all registered endpoints processed by DUM.
This Class is used to implement a primitive form of RPC using loose XML formatting.
std::map< resip::Data, resip::Data > Dictionary
Definition WebAdmin.hxx:30
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
std::condition_variable Condition
A condition variable that can be signaled or waited on, wraps POSIX/Windows implementations depending...
Definition Condition.hxx:51
IpVersion
An enumeration of IP versions.
void list()
Definition userAdmin.cxx:66