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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 #pragma once
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "HttpHandler.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <list>
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
26 #include <map>
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <stdint.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <boost/shared_ptr.hpp>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
30 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class ChunkStore;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class MongooseServer
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 private:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 // http://stackoverflow.com/questions/311166/stdauto-ptr-or-boostshared-ptr-for-pimpl-idiom
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 struct PImpl;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 boost::shared_ptr<PImpl> pimpl_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 typedef std::list<HttpHandler*> Handlers;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 Handlers handlers_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 23
diff changeset
44 typedef std::set<std::string> RegisteredUsers;
23
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
45 RegisteredUsers registeredUsers_;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
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
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
49 bool ssl_;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
50 std::string certificate_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 uint16_t port_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 bool IsRunning() const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 public:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 MongooseServer();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 ~MongooseServer();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 void SetPort(uint16_t port);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 uint16_t GetPort() const
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 return port_;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 void Start();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 void Stop();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
73 void RegisterUser(const char* username,
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
74 const char* password);
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
75
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 void RegisterHandler(HttpHandler* handler); // This takes the ownership
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
85 bool IsSslEnabled() const
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
86 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
87 return ssl_;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
88 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
89
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
90 void SetSslEnabled(bool enabled);
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
91
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
92 const std::string& GetSslCertificate() const
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
93 {
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
94 return certificate_;
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
95 }
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
96
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
97 void SetSslCertificate(const char* path);
62bd05fe4b7c support for ssl
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 void ClearHandlers();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 // Can return NULL if no handler is associated to this URI
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 HttpHandler* FindHandler(const UriComponents& forUri) const;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 }