Mercurial > hg > orthanc
annotate Core/HttpServer/MongooseServer.h @ 28:ef264c1e9ee5
fix msvc build
author | Administrator@jodogne-w01 |
---|---|
date | Wed, 29 Aug 2012 11:07:55 +0200 |
parents | dd1489098265 |
children | 96e57b863dd9 |
rev | line source |
---|---|
0 | 1 /** |
2 * Palantir - A Lightweight, RESTful DICOM Store | |
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 | |
30 namespace Palantir | |
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 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
47 bool authentication_; |
23 | 48 bool ssl_; |
49 std::string certificate_; | |
0 | 50 uint16_t port_; |
51 | |
52 bool IsRunning() const; | |
53 | |
54 public: | |
55 MongooseServer(); | |
56 | |
57 ~MongooseServer(); | |
58 | |
59 void SetPort(uint16_t port); | |
60 | |
61 uint16_t GetPort() const | |
62 { | |
63 return port_; | |
64 } | |
65 | |
66 void Start(); | |
67 | |
68 void Stop(); | |
69 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
70 void ClearUsers(); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
71 |
23 | 72 void RegisterUser(const char* username, |
73 const char* password); | |
74 | |
0 | 75 void RegisterHandler(HttpHandler* handler); // This takes the ownership |
76 | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
77 bool IsAuthenticationEnabled() const |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
78 { |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
79 return authentication_; |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
80 } |
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 void SetAuthenticationEnabled(bool enabled); |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
83 |
23 | 84 bool IsSslEnabled() const |
85 { | |
86 return ssl_; | |
87 } | |
88 | |
89 void SetSslEnabled(bool enabled); | |
90 | |
91 const std::string& GetSslCertificate() const | |
92 { | |
93 return certificate_; | |
94 } | |
95 | |
96 void SetSslCertificate(const char* path); | |
97 | |
0 | 98 void ClearHandlers(); |
99 | |
100 // Can return NULL if no handler is associated to this URI | |
101 HttpHandler* FindHandler(const UriComponents& forUri) const; | |
102 | |
103 ChunkStore& GetChunkStore(); | |
25
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
104 |
dd1489098265
basic http authentication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
24
diff
changeset
|
105 bool IsValidBasicHttpAuthentication(const std::string& basic) const; |
0 | 106 }; |
107 } |