Mercurial > hg > orthanc
annotate Core/WebServiceParameters.cpp @ 2922:40131f0c25b5
Orthanc configuration file can use environment variables
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 13:06:59 +0100 |
parents | 807169f85ba9 |
children | d924f9bb61cc |
rev | line source |
---|---|
808 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
808 | 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 | |
2020 | 34 #include "PrecompiledHeaders.h" |
35 #include "WebServiceParameters.h" | |
808 | 36 |
2659 | 37 #include "Logging.h" |
38 #include "OrthancException.h" | |
39 #include "SerializationToolbox.h" | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
40 #include "Toolbox.h" |
808 | 41 |
2145 | 42 #if ORTHANC_SANDBOXED == 0 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
43 # include "SystemToolbox.h" |
2145 | 44 #endif |
45 | |
2021 | 46 #include <cassert> |
47 | |
808 | 48 namespace Orthanc |
49 { | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
50 static const char* KEY_CERTIFICATE_FILE = "CertificateFile"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
51 static const char* KEY_CERTIFICATE_KEY_FILE = "CertificateKeyFile"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
52 static const char* KEY_CERTIFICATE_KEY_PASSWORD = "CertificateKeyPassword"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
53 static const char* KEY_HTTP_HEADERS = "HttpHeaders"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
54 static const char* KEY_PASSWORD = "Password"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
55 static const char* KEY_PKCS11 = "Pkcs11"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
56 static const char* KEY_URL = "Url"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
57 static const char* KEY_URL_2 = "URL"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
58 static const char* KEY_USERNAME = "Username"; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
59 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
60 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
61 static bool IsReservedKey(const std::string& key) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
62 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
63 return (key == KEY_CERTIFICATE_FILE || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
64 key == KEY_CERTIFICATE_KEY_FILE || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
65 key == KEY_CERTIFICATE_KEY_PASSWORD || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
66 key == KEY_HTTP_HEADERS || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
67 key == KEY_PASSWORD || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
68 key == KEY_PKCS11 || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
69 key == KEY_URL || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
70 key == KEY_URL_2 || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
71 key == KEY_USERNAME); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
72 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
73 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
74 |
2020 | 75 WebServiceParameters::WebServiceParameters() : |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
76 pkcs11Enabled_(false) |
808 | 77 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
78 SetUrl("http://127.0.0.1:8042/"); |
808 | 79 } |
80 | |
81 | |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
82 void WebServiceParameters::ClearClientCertificate() |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
83 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
84 certificateFile_.clear(); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
85 certificateKeyFile_.clear(); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
86 certificateKeyPassword_.clear(); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
87 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
88 |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
89 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
90 void WebServiceParameters::SetUrl(const std::string& url) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
91 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
92 if (!Toolbox::StartsWith(url, "http://") && |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
93 !Toolbox::StartsWith(url, "https://")) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
94 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
95 LOG(ERROR) << "Bad URL: " << url; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
96 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
97 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
98 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
99 // Add trailing slash if needed |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
100 if (url[url.size() - 1] == '/') |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
101 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
102 url_ = url; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
103 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
104 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
105 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
106 url_ = url + '/'; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
107 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
108 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
109 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
110 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
111 void WebServiceParameters::ClearCredentials() |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
112 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
113 username_.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
114 password_.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
115 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
116 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
117 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
118 void WebServiceParameters::SetCredentials(const std::string& username, |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
119 const std::string& password) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
120 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
121 if (username.empty() && |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
122 !password.empty()) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
123 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
124 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
125 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
126 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
127 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
128 username_ = username; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
129 password_ = password; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
130 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
131 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
132 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
133 |
2020 | 134 void WebServiceParameters::SetClientCertificate(const std::string& certificateFile, |
135 const std::string& certificateKeyFile, | |
136 const std::string& certificateKeyPassword) | |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
137 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
138 if (certificateFile.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
139 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
140 throw OrthancException(ErrorCode_ParameterOutOfRange); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
141 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
142 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
143 if (certificateKeyPassword.empty()) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
144 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
145 LOG(ERROR) << "The password for the HTTPS certificate is not provided: " << certificateFile; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
146 throw OrthancException(ErrorCode_BadFileFormat); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
147 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
148 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
149 certificateFile_ = certificateFile; |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
150 certificateKeyFile_ = certificateKeyFile; |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
151 certificateKeyPassword_ = certificateKeyPassword; |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
152 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
153 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
154 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
155 void WebServiceParameters::FromSimpleFormat(const Json::Value& peer) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
156 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
157 assert(peer.isArray()); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
158 |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
159 pkcs11Enabled_ = false; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
160 ClearClientCertificate(); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
161 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
162 if (peer.size() != 1 && |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
163 peer.size() != 3) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
164 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
165 throw OrthancException(ErrorCode_BadFileFormat); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
166 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
167 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
168 SetUrl(peer.get(0u, "").asString()); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
169 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
170 if (peer.size() == 1) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
171 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
172 ClearCredentials(); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
173 } |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
174 else if (peer.size() == 2) |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
175 { |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
176 LOG(ERROR) << "The HTTP password is not provided"; |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
177 throw OrthancException(ErrorCode_BadFileFormat); |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
178 } |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
179 else if (peer.size() == 3) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
180 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
181 SetCredentials(peer.get(1u, "").asString(), |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
182 peer.get(2u, "").asString()); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
183 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
184 else |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
185 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
186 throw OrthancException(ErrorCode_BadFileFormat); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
187 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
188 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
189 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
190 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
191 static std::string GetStringMember(const Json::Value& peer, |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
192 const std::string& key, |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
193 const std::string& defaultValue) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
194 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
195 if (!peer.isMember(key)) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
196 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
197 return defaultValue; |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
198 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
199 else if (peer[key].type() != Json::stringValue) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
200 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
201 throw OrthancException(ErrorCode_BadFileFormat); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
202 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
203 else |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
204 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
205 return peer[key].asString(); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
206 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
207 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
208 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
209 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
210 void WebServiceParameters::FromAdvancedFormat(const Json::Value& peer) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
211 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
212 assert(peer.isObject()); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
213 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
214 std::string url = GetStringMember(peer, KEY_URL, ""); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
215 if (url.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
216 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
217 SetUrl(GetStringMember(peer, KEY_URL_2, "")); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
218 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
219 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
220 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
221 SetUrl(url); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
222 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
223 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
224 SetCredentials(GetStringMember(peer, KEY_USERNAME, ""), |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
225 GetStringMember(peer, KEY_PASSWORD, "")); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
226 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
227 std::string file = GetStringMember(peer, KEY_CERTIFICATE_FILE, ""); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
228 if (!file.empty()) |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
229 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
230 SetClientCertificate(file, GetStringMember(peer, KEY_CERTIFICATE_KEY_FILE, ""), |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
231 GetStringMember(peer, KEY_CERTIFICATE_KEY_PASSWORD, "")); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
232 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
233 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
234 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
235 ClearClientCertificate(); |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
236 } |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
237 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
238 if (peer.isMember(KEY_PKCS11)) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
239 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
240 if (peer[KEY_PKCS11].type() == Json::booleanValue) |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
241 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
242 pkcs11Enabled_ = peer[KEY_PKCS11].asBool(); |
2022
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
243 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
244 else |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
245 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
246 throw OrthancException(ErrorCode_BadFileFormat); |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
247 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
248 } |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
249 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
250 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
251 pkcs11Enabled_ = false; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
252 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
253 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
254 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
255 headers_.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
256 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
257 if (peer.isMember(KEY_HTTP_HEADERS)) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
258 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
259 const Json::Value& h = peer[KEY_HTTP_HEADERS]; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
260 if (h.type() != Json::objectValue) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
261 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
262 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
263 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
264 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
265 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
266 Json::Value::Members keys = h.getMemberNames(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
267 for (size_t i = 0; i < keys.size(); i++) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
268 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
269 const Json::Value& value = h[keys[i]]; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
270 if (value.type() != Json::stringValue) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
271 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
272 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
273 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
274 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
275 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
276 headers_[keys[i]] = value.asString(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
277 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
278 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
279 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
280 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
281 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
282 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
283 userProperties_.clear(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
284 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
285 const Json::Value::Members members = peer.getMemberNames(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
286 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
287 for (Json::Value::Members::const_iterator it = members.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
288 it != members.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
289 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
290 if (!IsReservedKey(*it)) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
291 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
292 if (peer[*it].type() != Json::stringValue) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
293 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
294 throw OrthancException(ErrorCode_BadFileFormat); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
295 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
296 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
297 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
298 userProperties_[*it] = peer[*it].asString(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
299 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
300 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
301 } |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
302 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
303 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
304 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
305 void WebServiceParameters::Unserialize(const Json::Value& peer) |
808 | 306 { |
307 try | |
308 { | |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
309 if (peer.isArray()) |
808 | 310 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
311 FromSimpleFormat(peer); |
808 | 312 } |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
313 else if (peer.isObject()) |
808 | 314 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
315 FromAdvancedFormat(peer); |
808 | 316 } |
317 else | |
318 { | |
319 throw OrthancException(ErrorCode_BadFileFormat); | |
320 } | |
321 } | |
2042 | 322 catch (OrthancException&) |
323 { | |
324 throw; | |
325 } | |
808 | 326 catch (...) |
327 { | |
328 throw OrthancException(ErrorCode_BadFileFormat); | |
329 } | |
330 } | |
331 | |
332 | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
333 void WebServiceParameters::ListHttpHeaders(std::set<std::string>& target) const |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
334 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
335 target.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
336 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
337 for (Dictionary::const_iterator it = headers_.begin(); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
338 it != headers_.end(); ++it) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
339 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
340 target.insert(it->first); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
341 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
342 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
343 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
344 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
345 bool WebServiceParameters::LookupHttpHeader(std::string& value, |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
346 const std::string& key) const |
808 | 347 { |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
348 Dictionary::const_iterator found = headers_.find(key); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
349 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
350 if (found == headers_.end()) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
351 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
352 return false; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
353 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
354 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
355 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
356 value = found->second; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
357 return true; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
358 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
359 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
360 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
361 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
362 void WebServiceParameters::AddUserProperty(const std::string& key, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
363 const std::string& value) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
364 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
365 if (IsReservedKey(key)) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
366 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
367 LOG(ERROR) << "Cannot use this reserved key to name an user property: " << key; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
368 throw OrthancException(ErrorCode_ParameterOutOfRange); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
369 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
370 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
371 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
372 userProperties_[key] = value; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
373 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
374 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
375 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
376 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
377 void WebServiceParameters::ListUserProperties(std::set<std::string>& target) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
378 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
379 target.clear(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
380 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
381 for (Dictionary::const_iterator it = userProperties_.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
382 it != userProperties_.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
383 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
384 target.insert(it->first); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
385 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
386 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
387 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
388 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
389 bool WebServiceParameters::LookupUserProperty(std::string& value, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
390 const std::string& key) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
391 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
392 Dictionary::const_iterator found = userProperties_.find(key); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
393 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
394 if (found == userProperties_.end()) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
395 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
396 return false; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
397 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
398 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
399 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
400 value = found->second; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
401 return true; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
402 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
403 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
404 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
405 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
406 bool WebServiceParameters::IsAdvancedFormatNeeded() const |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
407 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
408 return (!certificateFile_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
409 !certificateKeyFile_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
410 !certificateKeyPassword_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
411 pkcs11Enabled_ || |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
412 !headers_.empty() || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
413 !userProperties_.empty()); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
414 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
415 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
416 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
417 void WebServiceParameters::Serialize(Json::Value& value, |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
418 bool forceAdvancedFormat, |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
419 bool includePasswords) const |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
420 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
421 if (forceAdvancedFormat || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
422 IsAdvancedFormatNeeded()) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
423 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
424 value = Json::objectValue; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
425 value[KEY_URL] = url_; |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
426 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
427 if (!username_.empty() || |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
428 !password_.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
429 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
430 value[KEY_USERNAME] = username_; |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
431 |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
432 if (includePasswords) |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
433 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
434 value[KEY_PASSWORD] = password_; |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
435 } |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
436 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
437 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
438 if (!certificateFile_.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
439 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
440 value[KEY_CERTIFICATE_FILE] = certificateFile_; |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
441 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
442 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
443 if (!certificateKeyFile_.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
444 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
445 value[KEY_CERTIFICATE_KEY_FILE] = certificateKeyFile_; |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
446 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
447 |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
448 if (!certificateKeyPassword_.empty() && |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
449 includePasswords) |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
450 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
451 value[KEY_CERTIFICATE_KEY_PASSWORD] = certificateKeyPassword_; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
452 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
453 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
454 value[KEY_PKCS11] = pkcs11Enabled_; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
455 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
456 value[KEY_HTTP_HEADERS] = Json::objectValue; |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
457 for (Dictionary::const_iterator it = headers_.begin(); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
458 it != headers_.end(); ++it) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
459 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
460 value[KEY_HTTP_HEADERS][it->first] = it->second; |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
461 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
462 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
463 for (Dictionary::const_iterator it = userProperties_.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
464 it != userProperties_.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
465 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
466 value[it->first] = it->second; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
467 } |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
468 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
469 else |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
470 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
471 value = Json::arrayValue; |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
472 value.append(url_); |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
473 |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
474 if (!username_.empty() || |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
475 !password_.empty()) |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
476 { |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
477 value.append(username_); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
478 value.append(includePasswords ? password_ : ""); |
2019
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
479 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
480 } |
9c9332e486ca
HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
481 } |
2655 | 482 |
483 | |
2779 | 484 #if ORTHANC_SANDBOXED == 0 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
485 void WebServiceParameters::CheckClientCertificate() const |
2655 | 486 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
487 if (!certificateFile_.empty()) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
488 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
489 if (!SystemToolbox::IsRegularFile(certificateFile_)) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
490 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
491 LOG(ERROR) << "Cannot open certificate file: " << certificateFile_; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
492 throw OrthancException(ErrorCode_InexistentFile); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
493 } |
2659 | 494 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
495 if (!certificateKeyFile_.empty() && |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
496 !SystemToolbox::IsRegularFile(certificateKeyFile_)) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
497 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
498 LOG(ERROR) << "Cannot open key file: " << certificateKeyFile_; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
499 throw OrthancException(ErrorCode_InexistentFile); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
500 } |
2659 | 501 } |
2655 | 502 } |
2779 | 503 #endif |
808 | 504 } |