Mercurial > hg > orthanc
comparison OrthancFramework/Sources/WebServiceParameters.h @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | Core/WebServiceParameters.h@f9863630ec7f |
children | bf7b9edf6b81 |
comparison
equal
deleted
inserted
replaced
4043:6c6239aec462 | 4044:d25f4c0fa160 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
36 #include "OrthancFramework.h" | |
37 | |
38 #if !defined(ORTHANC_SANDBOXED) | |
39 # error The macro ORTHANC_SANDBOXED must be defined | |
40 #endif | |
41 | |
42 #include <map> | |
43 #include <set> | |
44 #include <string> | |
45 #include <json/json.h> | |
46 | |
47 namespace Orthanc | |
48 { | |
49 class ORTHANC_PUBLIC WebServiceParameters | |
50 { | |
51 public: | |
52 typedef std::map<std::string, std::string> Dictionary; | |
53 | |
54 private: | |
55 std::string url_; | |
56 std::string username_; | |
57 std::string password_; | |
58 std::string certificateFile_; | |
59 std::string certificateKeyFile_; | |
60 std::string certificateKeyPassword_; | |
61 bool pkcs11Enabled_; | |
62 Dictionary headers_; | |
63 Dictionary userProperties_; | |
64 | |
65 void FromSimpleFormat(const Json::Value& peer); | |
66 | |
67 void FromAdvancedFormat(const Json::Value& peer); | |
68 | |
69 public: | |
70 WebServiceParameters(); | |
71 | |
72 WebServiceParameters(const Json::Value& serialized) | |
73 { | |
74 Unserialize(serialized); | |
75 } | |
76 | |
77 const std::string& GetUrl() const | |
78 { | |
79 return url_; | |
80 } | |
81 | |
82 void SetUrl(const std::string& url); | |
83 | |
84 void ClearCredentials(); | |
85 | |
86 void SetCredentials(const std::string& username, | |
87 const std::string& password); | |
88 | |
89 const std::string& GetUsername() const | |
90 { | |
91 return username_; | |
92 } | |
93 | |
94 const std::string& GetPassword() const | |
95 { | |
96 return password_; | |
97 } | |
98 | |
99 void ClearClientCertificate(); | |
100 | |
101 void SetClientCertificate(const std::string& certificateFile, | |
102 const std::string& certificateKeyFile, | |
103 const std::string& certificateKeyPassword); | |
104 | |
105 const std::string& GetCertificateFile() const | |
106 { | |
107 return certificateFile_; | |
108 } | |
109 | |
110 const std::string& GetCertificateKeyFile() const | |
111 { | |
112 return certificateKeyFile_; | |
113 } | |
114 | |
115 const std::string& GetCertificateKeyPassword() const | |
116 { | |
117 return certificateKeyPassword_; | |
118 } | |
119 | |
120 void SetPkcs11Enabled(bool enabled) | |
121 { | |
122 pkcs11Enabled_ = enabled; | |
123 } | |
124 | |
125 bool IsPkcs11Enabled() const | |
126 { | |
127 return pkcs11Enabled_; | |
128 } | |
129 | |
130 void AddHttpHeader(const std::string& key, | |
131 const std::string& value) | |
132 { | |
133 headers_[key] = value; | |
134 } | |
135 | |
136 void ClearHttpHeaders() | |
137 { | |
138 headers_.clear(); | |
139 } | |
140 | |
141 const Dictionary& GetHttpHeaders() const | |
142 { | |
143 return headers_; | |
144 } | |
145 | |
146 void ListHttpHeaders(std::set<std::string>& target) const; | |
147 | |
148 bool LookupHttpHeader(std::string& value, | |
149 const std::string& key) const; | |
150 | |
151 void AddUserProperty(const std::string& key, | |
152 const std::string& value); | |
153 | |
154 void ClearUserProperties() | |
155 { | |
156 userProperties_.clear(); | |
157 } | |
158 | |
159 const Dictionary& GetUserProperties() const | |
160 { | |
161 return userProperties_; | |
162 } | |
163 | |
164 void ListUserProperties(std::set<std::string>& target) const; | |
165 | |
166 bool LookupUserProperty(std::string& value, | |
167 const std::string& key) const; | |
168 | |
169 bool GetBooleanUserProperty(const std::string& key, | |
170 bool defaultValue) const; | |
171 | |
172 bool IsAdvancedFormatNeeded() const; | |
173 | |
174 void Unserialize(const Json::Value& peer); | |
175 | |
176 void Serialize(Json::Value& value, | |
177 bool forceAdvancedFormat, | |
178 bool includePasswords) const; | |
179 | |
180 #if ORTHANC_SANDBOXED == 0 | |
181 void CheckClientCertificate() const; | |
182 #endif | |
183 | |
184 void FormatPublic(Json::Value& target) const; | |
185 }; | |
186 } |