Mercurial > hg > orthanc
annotate OrthancFramework/Sources/WebServiceParameters.cpp @ 4494:39192eb9b43d
New metadata automatically computed at the instance level: "PixelDataOffset"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Feb 2021 15:31:00 +0100 |
parents | d9473bd5ed43 |
children | 017ab543e6ef |
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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
808 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
10 * the License, or (at your option) any later version. |
808 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
15 * Lesser General Public License for more details. |
808 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4087
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
808 | 20 **/ |
21 | |
22 | |
2020 | 23 #include "PrecompiledHeaders.h" |
24 #include "WebServiceParameters.h" | |
808 | 25 |
2659 | 26 #include "Logging.h" |
27 #include "OrthancException.h" | |
28 #include "SerializationToolbox.h" | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
29 #include "Toolbox.h" |
808 | 30 |
2145 | 31 #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
|
32 # include "SystemToolbox.h" |
2145 | 33 #endif |
34 | |
4072
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
35 #include <boost/algorithm/string/find.hpp> |
2021 | 36 #include <cassert> |
37 | |
808 | 38 namespace Orthanc |
39 { | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
50 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
51 static bool IsReservedKey(const std::string& key) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
52 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
53 return (key == KEY_CERTIFICATE_FILE || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
54 key == KEY_CERTIFICATE_KEY_FILE || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
55 key == KEY_CERTIFICATE_KEY_PASSWORD || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
56 key == KEY_HTTP_HEADERS || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
57 key == KEY_PASSWORD || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
58 key == KEY_PKCS11 || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
59 key == KEY_URL || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
60 key == KEY_URL_2 || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
61 key == KEY_USERNAME); |
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 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
64 |
2020 | 65 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
|
66 pkcs11Enabled_(false) |
808 | 67 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
68 SetUrl("http://127.0.0.1:8042/"); |
808 | 69 } |
70 | |
4300 | 71 WebServiceParameters::WebServiceParameters(const Json::Value &serialized) |
72 { | |
73 Unserialize(serialized); | |
74 } | |
75 | |
76 const std::string &WebServiceParameters::GetUrl() const | |
77 { | |
78 return url_; | |
79 } | |
80 | |
808 | 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 { |
4072
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
92 if (boost::find_first(url, "://")) |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
93 { |
4072
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
94 // Only allow the HTTP and HTTPS protocols |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
95 if (!Toolbox::StartsWith(url, "http://") && |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
96 !Toolbox::StartsWith(url, "https://")) |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
97 { |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
98 throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url); |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
99 } |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
100 } |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
101 |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
102 if (url.empty()) |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
103 { |
3dda0d73193c
fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
104 throw OrthancException(ErrorCode_BadFileFormat, "Empty URL"); |
2800
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 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
107 // 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
|
108 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
|
109 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
110 url_ = url; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
111 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
112 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
113 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
114 url_ = url + '/'; |
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 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
119 void WebServiceParameters::ClearCredentials() |
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 username_.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
122 password_.clear(); |
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 |
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 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
|
127 const std::string& password) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
128 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
129 if (username.empty() && |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
130 !password.empty()) |
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 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
133 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
134 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
135 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
136 username_ = username; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
137 password_ = password; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
138 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
139 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
140 |
4300 | 141 const std::string &WebServiceParameters::GetUsername() const |
142 { | |
143 return username_; | |
144 } | |
145 | |
146 const std::string &WebServiceParameters::GetPassword() const | |
147 { | |
148 return password_; | |
149 } | |
150 | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
151 |
2020 | 152 void WebServiceParameters::SetClientCertificate(const std::string& certificateFile, |
153 const std::string& certificateKeyFile, | |
154 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
|
155 { |
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 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
|
157 { |
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 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
|
159 } |
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
|
160 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
161 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
|
162 { |
4194
2bc49197f806
HTTP client: allow empty CertificateKeyPassword
Alain Mazy <alain@mazy.be>
parents:
4119
diff
changeset
|
163 LOG(WARNING) << "No password specified for 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
|
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 |
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 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
|
167 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
|
168 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
|
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 |
4300 | 171 const std::string &WebServiceParameters::GetCertificateFile() const |
172 { | |
173 return certificateFile_; | |
174 } | |
175 | |
176 const std::string &WebServiceParameters::GetCertificateKeyFile() const | |
177 { | |
178 return certificateKeyFile_; | |
179 } | |
180 | |
181 const std::string &WebServiceParameters::GetCertificateKeyPassword() const | |
182 { | |
183 return certificateKeyPassword_; | |
184 } | |
185 | |
186 void WebServiceParameters::SetPkcs11Enabled(bool enabled) | |
187 { | |
188 pkcs11Enabled_ = enabled; | |
189 } | |
190 | |
191 bool WebServiceParameters::IsPkcs11Enabled() const | |
192 { | |
193 return pkcs11Enabled_; | |
194 } | |
195 | |
196 void WebServiceParameters::AddHttpHeader(const std::string &key, const std::string &value) | |
197 { | |
198 headers_[key] = value; | |
199 } | |
200 | |
201 void WebServiceParameters::ClearHttpHeaders() | |
202 { | |
203 headers_.clear(); | |
204 } | |
205 | |
206 const WebServiceParameters::Dictionary &WebServiceParameters::GetHttpHeaders() const | |
207 { | |
208 return headers_; | |
209 } | |
210 | |
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 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
212 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
|
213 { |
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
|
214 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
|
215 |
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
|
216 pkcs11Enabled_ = false; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
217 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
|
218 |
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
|
219 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
|
220 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
|
221 { |
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 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
|
223 } |
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
|
224 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
225 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
|
226 |
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
|
227 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
|
228 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
229 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
|
230 } |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
231 else if (peer.size() == 2) |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
232 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
233 throw OrthancException(ErrorCode_BadFileFormat, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
234 "The HTTP password is not provided"); |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
235 } |
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
|
236 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
|
237 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
238 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
|
239 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
|
240 } |
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
|
241 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
|
242 { |
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
|
243 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
|
244 } |
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
|
245 } |
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
|
246 |
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
|
247 |
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
|
248 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
|
249 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
|
250 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
|
251 { |
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
|
252 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
|
253 { |
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
|
254 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
|
255 } |
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
|
256 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
|
257 { |
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
|
258 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
|
259 } |
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
|
260 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
|
261 { |
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
|
262 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
|
263 } |
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
|
264 } |
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
|
265 |
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
|
266 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
267 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
|
268 { |
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
|
269 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
|
270 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
271 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
|
272 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
|
273 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
274 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
|
275 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
276 else |
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 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
|
279 } |
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
|
280 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
281 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
|
282 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
|
283 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
284 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
|
285 if (!file.empty()) |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
286 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
287 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
|
288 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
|
289 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
290 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
291 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
292 ClearClientCertificate(); |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
293 } |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
294 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
295 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
|
296 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
297 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
|
298 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
299 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
|
300 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
301 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
|
302 { |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
303 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
|
304 } |
fefbe71c2272
Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2021
diff
changeset
|
305 } |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
306 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
307 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
308 pkcs11Enabled_ = false; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
309 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
310 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
311 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
312 headers_.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
313 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
314 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
|
315 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
316 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
|
317 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
|
318 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
319 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
320 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
321 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
322 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
323 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
|
324 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
|
325 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
326 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
|
327 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
|
328 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
329 throw OrthancException(ErrorCode_BadFileFormat); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
330 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
331 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
332 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
333 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
|
334 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
335 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
336 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
337 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
338 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
339 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
340 userProperties_.clear(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
341 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
342 const Json::Value::Members members = peer.getMemberNames(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
343 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
344 for (Json::Value::Members::const_iterator it = members.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
345 it != members.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
346 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
347 if (!IsReservedKey(*it)) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
348 { |
3444
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
349 switch (peer[*it].type()) |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
350 { |
3444
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
351 case Json::stringValue: |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
352 userProperties_[*it] = peer[*it].asString(); |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
353 break; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
354 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
355 case Json::booleanValue: |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
356 userProperties_[*it] = peer[*it].asBool() ? "1" : "0"; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
357 break; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
358 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
359 case Json::intValue: |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
360 userProperties_[*it] = boost::lexical_cast<std::string>(peer[*it].asInt()); |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
361 break; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
362 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
363 default: |
3716
ae0e3fd609df
sample for "Manufacturer" option in "DicomModalities" config
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
364 throw OrthancException(ErrorCode_BadFileFormat, |
ae0e3fd609df
sample for "Manufacturer" option in "DicomModalities" config
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
365 "User-defined properties associated with a Web service must be strings: " + *it); |
2823
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 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
368 } |
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
|
369 } |
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
|
370 |
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
|
371 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
372 void WebServiceParameters::Unserialize(const Json::Value& peer) |
808 | 373 { |
374 try | |
375 { | |
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
|
376 if (peer.isArray()) |
808 | 377 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
378 FromSimpleFormat(peer); |
808 | 379 } |
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
|
380 else if (peer.isObject()) |
808 | 381 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
382 FromAdvancedFormat(peer); |
808 | 383 } |
384 else | |
385 { | |
386 throw OrthancException(ErrorCode_BadFileFormat); | |
387 } | |
388 } | |
2042 | 389 catch (OrthancException&) |
390 { | |
391 throw; | |
392 } | |
808 | 393 catch (...) |
394 { | |
395 throw OrthancException(ErrorCode_BadFileFormat); | |
396 } | |
397 } | |
398 | |
399 | |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
400 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
|
401 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
402 target.clear(); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
403 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
404 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
|
405 it != headers_.end(); ++it) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
406 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
407 target.insert(it->first); |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
408 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
409 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
410 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
411 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
412 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
|
413 const std::string& key) const |
808 | 414 { |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
415 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
|
416 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
417 if (found == headers_.end()) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
418 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
419 return false; |
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 else |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
422 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
423 value = found->second; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
424 return true; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
425 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
426 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
427 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
428 |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
429 void WebServiceParameters::AddUserProperty(const std::string& key, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
430 const std::string& value) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
431 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
432 if (IsReservedKey(key)) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
433 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
434 throw OrthancException( |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
435 ErrorCode_ParameterOutOfRange, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
436 "Cannot use this reserved key to name an user property: " + key); |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
437 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
438 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
439 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
440 userProperties_[key] = value; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
441 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
442 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
443 |
4300 | 444 void WebServiceParameters::ClearUserProperties() |
445 { | |
446 userProperties_.clear(); | |
447 } | |
448 | |
449 const WebServiceParameters::Dictionary &WebServiceParameters::GetUserProperties() const | |
450 { | |
451 return userProperties_; | |
452 } | |
453 | |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
454 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
455 void WebServiceParameters::ListUserProperties(std::set<std::string>& target) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
456 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
457 target.clear(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
458 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
459 for (Dictionary::const_iterator it = userProperties_.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
460 it != userProperties_.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
461 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
462 target.insert(it->first); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
463 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
464 } |
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 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
467 bool WebServiceParameters::LookupUserProperty(std::string& value, |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
468 const std::string& key) const |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
469 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
470 Dictionary::const_iterator found = userProperties_.find(key); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
471 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
472 if (found == userProperties_.end()) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
473 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
474 return false; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
475 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
476 else |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
477 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
478 value = found->second; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
479 return true; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
480 } |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
481 } |
3444
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
482 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
483 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
484 bool WebServiceParameters::GetBooleanUserProperty(const std::string& key, |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
485 bool defaultValue) const |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
486 { |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
487 Dictionary::const_iterator found = userProperties_.find(key); |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
488 |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
489 if (found == userProperties_.end()) |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
490 { |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
491 return defaultValue; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
492 } |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
493 else if (found->second == "0" || |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
494 found->second == "false") |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
495 { |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
496 return false; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
497 } |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
498 else if (found->second == "1" || |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
499 found->second == "true") |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
500 { |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
501 return true; |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
502 } |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
503 else |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
504 { |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
505 throw OrthancException(ErrorCode_BadFileFormat, "Bad value for a Boolean user property in the parameters " |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
506 "of a Web service: Property \"" + key + "\" equals: " + found->second); |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
507 } |
6fe42a335a80
WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
508 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
509 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
510 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
511 bool WebServiceParameters::IsAdvancedFormatNeeded() const |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
512 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
513 return (!certificateFile_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
514 !certificateKeyFile_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
515 !certificateKeyPassword_.empty() || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
516 pkcs11Enabled_ || |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
517 !headers_.empty() || |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
518 !userProperties_.empty()); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
519 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
520 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
521 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
522 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
|
523 bool forceAdvancedFormat, |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
524 bool includePasswords) const |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
525 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
526 if (forceAdvancedFormat || |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
527 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
|
528 { |
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
|
529 value = Json::objectValue; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
530 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
|
531 |
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
|
532 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
|
533 !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
|
534 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
535 value[KEY_USERNAME] = username_; |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
536 |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
537 if (includePasswords) |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
538 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
539 value[KEY_PASSWORD] = password_; |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
540 } |
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
|
541 } |
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
|
542 |
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
|
543 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
|
544 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
545 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
|
546 } |
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
|
547 |
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
|
548 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
|
549 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
550 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
|
551 } |
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
|
552 |
2669
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
553 if (!certificateKeyPassword_.empty() && |
eaf10085ffa1
no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2659
diff
changeset
|
554 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
|
555 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
556 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
|
557 } |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
558 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
559 value[KEY_PKCS11] = pkcs11Enabled_; |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
560 |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
561 value[KEY_HTTP_HEADERS] = Json::objectValue; |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
562 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
|
563 it != headers_.end(); ++it) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
564 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
565 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
|
566 } |
2823
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
567 |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
568 for (Dictionary::const_iterator it = userProperties_.begin(); |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
569 it != userProperties_.end(); ++it) |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
570 { |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
571 value[it->first] = it->second; |
807169f85ba9
OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
572 } |
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
|
573 } |
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
|
574 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
|
575 { |
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
|
576 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
|
577 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
|
578 |
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
|
579 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
|
580 !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
|
581 { |
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
|
582 value.append(username_); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
583 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
|
584 } |
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
|
585 } |
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
|
586 } |
2655 | 587 |
588 | |
2779 | 589 #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
|
590 void WebServiceParameters::CheckClientCertificate() const |
2655 | 591 { |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
592 if (!certificateFile_.empty()) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
593 { |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
594 if (!SystemToolbox::IsRegularFile(certificateFile_)) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
595 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
596 throw OrthancException(ErrorCode_InexistentFile, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
597 "Cannot open certificate file: " + certificateFile_); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
598 } |
2659 | 599 |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
600 if (!certificateKeyFile_.empty() && |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
601 !SystemToolbox::IsRegularFile(certificateKeyFile_)) |
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
602 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
603 throw OrthancException(ErrorCode_InexistentFile, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2823
diff
changeset
|
604 "Cannot open key file: " + certificateKeyFile_); |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2779
diff
changeset
|
605 } |
2659 | 606 } |
2655 | 607 } |
2779 | 608 #endif |
3192
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
609 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
610 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
611 void WebServiceParameters::FormatPublic(Json::Value& target) const |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
612 { |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
613 target = Json::objectValue; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
614 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
615 // Only return the public information identifying the destination. |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
616 // "Security"-related information such as passwords and HTTP |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
617 // headers are shown as "null" values. |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
618 target[KEY_URL] = url_; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
619 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
620 if (!username_.empty()) |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
621 { |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
622 target[KEY_USERNAME] = username_; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
623 target[KEY_PASSWORD] = Json::nullValue; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
624 } |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
625 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
626 if (!certificateFile_.empty()) |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
627 { |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
628 target[KEY_CERTIFICATE_FILE] = certificateFile_; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
629 target[KEY_CERTIFICATE_KEY_FILE] = Json::nullValue; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
630 target[KEY_CERTIFICATE_KEY_PASSWORD] = Json::nullValue; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
631 } |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
632 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
633 target[KEY_PKCS11] = pkcs11Enabled_; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
634 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
635 Json::Value headers = Json::arrayValue; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
636 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
637 for (Dictionary::const_iterator it = headers_.begin(); |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
638 it != headers_.end(); ++it) |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
639 { |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
640 // Only list the HTTP headers, not their value |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
641 headers.append(it->first); |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
642 } |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
643 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
644 target[KEY_HTTP_HEADERS] = headers; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
645 |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
646 for (Dictionary::const_iterator it = userProperties_.begin(); |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
647 it != userProperties_.end(); ++it) |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
648 { |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
649 target[it->first] = it->second; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
650 } |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
651 } |
808 | 652 } |