Mercurial > hg > orthanc
annotate Core/HttpServer/MongooseServer.h @ 376:2cef9c2d4148
separate path for SQLite index, manual loading of external dictionaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 Apr 2013 11:13:51 +0200 |
parents | 1ac3aacd10a5 |
children | bdd72233b105 |
rev | line source |
---|---|
0 | 1 /** |
59 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
0 | 3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
4 * Belgium | |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
33 #pragma once | |
34 | |
35 #include "HttpHandler.h" | |
36 | |
37 #include <list> | |
23 | 38 #include <map> |
217 | 39 #include <set> |
0 | 40 #include <stdint.h> |
41 #include <boost/shared_ptr.hpp> | |
42 | |
59 | 43 namespace Orthanc |
0 | 44 { |
45 class ChunkStore; | |
46 | |
47 class MongooseServer | |
48 { | |
49 private: | |
50 // http://stackoverflow.com/questions/311166/stdauto-ptr-or-boostshared-ptr-for-pimpl-idiom | |
51 struct PImpl; | |
52 boost::shared_ptr<PImpl> pimpl_; | |
53 | |
54 typedef std::list<HttpHandler*> Handlers; | |
55 Handlers handlers_; | |
56 | |
24 | 57 typedef std::set<std::string> RegisteredUsers; |
23 | 58 RegisteredUsers registeredUsers_; |
59 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
60 bool remoteAllowed_; |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
61 bool authentication_; |
23 | 62 bool ssl_; |
63 std::string certificate_; | |
0 | 64 uint16_t port_; |
65 | |
66 bool IsRunning() const; | |
67 | |
68 public: | |
69 MongooseServer(); | |
70 | |
71 ~MongooseServer(); | |
72 | |
128 | 73 void SetPortNumber(uint16_t port); |
0 | 74 |
128 | 75 uint16_t GetPortNumber() const |
0 | 76 { |
77 return port_; | |
78 } | |
79 | |
80 void Start(); | |
81 | |
82 void Stop(); | |
83 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
84 void ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
85 |
23 | 86 void RegisterUser(const char* username, |
87 const char* password); | |
88 | |
0 | 89 void RegisterHandler(HttpHandler* handler); // This takes the ownership |
90 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
91 bool IsAuthenticationEnabled() const |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
92 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
93 return authentication_; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
94 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
95 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
96 void SetAuthenticationEnabled(bool enabled); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
97 |
23 | 98 bool IsSslEnabled() const |
99 { | |
100 return ssl_; | |
101 } | |
102 | |
103 void SetSslEnabled(bool enabled); | |
104 | |
105 const std::string& GetSslCertificate() const | |
106 { | |
107 return certificate_; | |
108 } | |
109 | |
110 void SetSslCertificate(const char* path); | |
111 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
112 bool IsRemoteAccessAllowed() const |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
113 { |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
114 return remoteAllowed_; |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
115 } |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
116 |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
117 void SetRemoteAccessAllowed(bool allowed); |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
118 |
0 | 119 void ClearHandlers(); |
120 | |
121 // Can return NULL if no handler is associated to this URI | |
122 HttpHandler* FindHandler(const UriComponents& forUri) const; | |
123 | |
124 ChunkStore& GetChunkStore(); | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
125 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
126 bool IsValidBasicHttpAuthentication(const std::string& basic) const; |
0 | 127 }; |
128 } |