Mercurial > hg > orthanc
annotate Core/HttpServer/MongooseServer.h @ 155:93e1b0e3b83a
filenames when downloading json/dicom
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 23 Oct 2012 15:43:46 +0200 |
parents | fe180eae201d |
children | 1ac3aacd10a5 |
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> |
0 | 39 #include <stdint.h> |
40 #include <boost/shared_ptr.hpp> | |
41 | |
59 | 42 namespace Orthanc |
0 | 43 { |
44 class ChunkStore; | |
45 | |
46 class MongooseServer | |
47 { | |
48 private: | |
49 // http://stackoverflow.com/questions/311166/stdauto-ptr-or-boostshared-ptr-for-pimpl-idiom | |
50 struct PImpl; | |
51 boost::shared_ptr<PImpl> pimpl_; | |
52 | |
53 typedef std::list<HttpHandler*> Handlers; | |
54 Handlers handlers_; | |
55 | |
24 | 56 typedef std::set<std::string> RegisteredUsers; |
23 | 57 RegisteredUsers registeredUsers_; |
58 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
59 bool remoteAllowed_; |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
60 bool authentication_; |
23 | 61 bool ssl_; |
62 std::string certificate_; | |
0 | 63 uint16_t port_; |
64 | |
65 bool IsRunning() const; | |
66 | |
67 public: | |
68 MongooseServer(); | |
69 | |
70 ~MongooseServer(); | |
71 | |
128 | 72 void SetPortNumber(uint16_t port); |
0 | 73 |
128 | 74 uint16_t GetPortNumber() const |
0 | 75 { |
76 return port_; | |
77 } | |
78 | |
79 void Start(); | |
80 | |
81 void Stop(); | |
82 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
83 void ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
84 |
23 | 85 void RegisterUser(const char* username, |
86 const char* password); | |
87 | |
0 | 88 void RegisterHandler(HttpHandler* handler); // This takes the ownership |
89 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
90 bool IsAuthenticationEnabled() const |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
91 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
92 return authentication_; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
93 } |
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 void SetAuthenticationEnabled(bool enabled); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
96 |
23 | 97 bool IsSslEnabled() const |
98 { | |
99 return ssl_; | |
100 } | |
101 | |
102 void SetSslEnabled(bool enabled); | |
103 | |
104 const std::string& GetSslCertificate() const | |
105 { | |
106 return certificate_; | |
107 } | |
108 | |
109 void SetSslCertificate(const char* path); | |
110 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
111 bool IsRemoteAccessAllowed() const |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
112 { |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
113 return remoteAllowed_; |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
114 } |
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 void SetRemoteAccessAllowed(bool allowed); |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
117 |
0 | 118 void ClearHandlers(); |
119 | |
120 // Can return NULL if no handler is associated to this URI | |
121 HttpHandler* FindHandler(const UriComponents& forUri) const; | |
122 | |
123 ChunkStore& GetChunkStore(); | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
124 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
125 bool IsValidBasicHttpAuthentication(const std::string& basic) const; |
0 | 126 }; |
127 } |