Mercurial > hg > orthanc
annotate Core/HttpServer/MongooseServer.h @ 111:0fc3b69c0357
preparing for release
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Oct 2012 12:45:24 +0200 |
parents | c996319e90bc |
children | 2a24f43d9dca |
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. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 **/ | |
19 | |
20 | |
21 #pragma once | |
22 | |
23 #include "HttpHandler.h" | |
24 | |
25 #include <list> | |
23 | 26 #include <map> |
0 | 27 #include <stdint.h> |
28 #include <boost/shared_ptr.hpp> | |
29 | |
59 | 30 namespace Orthanc |
0 | 31 { |
32 class ChunkStore; | |
33 | |
34 class MongooseServer | |
35 { | |
36 private: | |
37 // http://stackoverflow.com/questions/311166/stdauto-ptr-or-boostshared-ptr-for-pimpl-idiom | |
38 struct PImpl; | |
39 boost::shared_ptr<PImpl> pimpl_; | |
40 | |
41 typedef std::list<HttpHandler*> Handlers; | |
42 Handlers handlers_; | |
43 | |
24 | 44 typedef std::set<std::string> RegisteredUsers; |
23 | 45 RegisteredUsers registeredUsers_; |
46 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
47 bool remoteAllowed_; |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
48 bool authentication_; |
23 | 49 bool ssl_; |
50 std::string certificate_; | |
0 | 51 uint16_t port_; |
52 | |
53 bool IsRunning() const; | |
54 | |
55 public: | |
56 MongooseServer(); | |
57 | |
58 ~MongooseServer(); | |
59 | |
60 void SetPort(uint16_t port); | |
61 | |
62 uint16_t GetPort() const | |
63 { | |
64 return port_; | |
65 } | |
66 | |
67 void Start(); | |
68 | |
69 void Stop(); | |
70 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
71 void ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
72 |
23 | 73 void RegisterUser(const char* username, |
74 const char* password); | |
75 | |
0 | 76 void RegisterHandler(HttpHandler* handler); // This takes the ownership |
77 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
78 bool IsAuthenticationEnabled() const |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
79 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
80 return authentication_; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
81 } |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
82 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
83 void SetAuthenticationEnabled(bool enabled); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
84 |
23 | 85 bool IsSslEnabled() const |
86 { | |
87 return ssl_; | |
88 } | |
89 | |
90 void SetSslEnabled(bool enabled); | |
91 | |
92 const std::string& GetSslCertificate() const | |
93 { | |
94 return certificate_; | |
95 } | |
96 | |
97 void SetSslCertificate(const char* path); | |
98 | |
34
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
99 bool IsRemoteAccessAllowed() const |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
100 { |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
101 return remoteAllowed_; |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
102 } |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
103 |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
104 void SetRemoteAccessAllowed(bool allowed); |
96e57b863dd9
option to disallow remote access
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
25
diff
changeset
|
105 |
0 | 106 void ClearHandlers(); |
107 | |
108 // Can return NULL if no handler is associated to this URI | |
109 HttpHandler* FindHandler(const UriComponents& forUri) const; | |
110 | |
111 ChunkStore& GetChunkStore(); | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
112 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
113 bool IsValidBasicHttpAuthentication(const std::string& basic) const; |
0 | 114 }; |
115 } |