annotate OrthancFramework/Sources/WebServiceParameters.cpp @ 4553:f21bc79e0f31

fix build on freebsd
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Mar 2021 13:48:45 +0100
parents 017ab543e6ef
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
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
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
23 #include "PrecompiledHeaders.h"
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
24 #include "WebServiceParameters.h"
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
26 #include "Logging.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
27 #include "OrthancException.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
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
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
2145
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
33 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2143
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
36 #include <cassert>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
37
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 namespace Orthanc
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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";
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
49 static const char* KEY_TIMEOUT = "Timeout";
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
50
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
51
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
52 static bool IsReservedKey(const std::string& key)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
53 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
54 return (key == KEY_CERTIFICATE_FILE ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
55 key == KEY_CERTIFICATE_KEY_FILE ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
56 key == KEY_CERTIFICATE_KEY_PASSWORD ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
57 key == KEY_HTTP_HEADERS ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
58 key == KEY_PASSWORD ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
59 key == KEY_PKCS11 ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
60 key == KEY_URL ||
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
61 key == KEY_URL_2 ||
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
62 key == KEY_USERNAME ||
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
63 key == KEY_TIMEOUT);
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
64 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
65
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
66
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
67 WebServiceParameters::WebServiceParameters() :
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
68 pkcs11Enabled_(false),
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
69 timeout_(0)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
71 SetUrl("http://127.0.0.1:8042/");
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
74 WebServiceParameters::WebServiceParameters(const Json::Value &serialized)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
75 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
76 Unserialize(serialized);
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
77 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
78
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
79 const std::string &WebServiceParameters::GetUrl() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
80 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
81 return url_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
82 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
83
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
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
85 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
86 {
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 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
88 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
89 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
90 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2021
diff changeset
91
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2021
diff changeset
92
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
93 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
94 {
4072
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
95 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
96 {
4072
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
97 // Only allow the HTTP and HTTPS protocols
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
98 if (!Toolbox::StartsWith(url, "http://") &&
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
99 !Toolbox::StartsWith(url, "https://"))
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 throw OrthancException(ErrorCode_BadFileFormat, "Bad URL: " + url);
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
102 }
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
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
105 if (url.empty())
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
106 {
3dda0d73193c fix doxygen, more tolerant WebServiceParameters::SetUrl()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
107 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
108 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
109
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
110 // 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
111 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
112 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
113 url_ = url;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
114 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
115 else
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 url_ = url + '/';
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 }
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
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
122 void WebServiceParameters::ClearCredentials()
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 username_.clear();
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
125 password_.clear();
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
126 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
127
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
128
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
129 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
130 const std::string& password)
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 if (username.empty() &&
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
133 !password.empty())
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
134 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
135 throw OrthancException(ErrorCode_BadFileFormat);
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
136 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
137 else
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 username_ = username;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
140 password_ = password;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
141 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
142 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
143
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
144 const std::string &WebServiceParameters::GetUsername() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
145 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
146 return username_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
147 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
148
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
149 const std::string &WebServiceParameters::GetPassword() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
150 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
151 return password_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
152 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
153
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
154
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
155 void WebServiceParameters::SetClientCertificate(const std::string& certificateFile,
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
156 const std::string& certificateKeyFile,
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2019
diff changeset
157 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
158 {
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 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
160 {
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
161 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
162 }
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
163
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
164 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
165 {
4194
2bc49197f806 HTTP client: allow empty CertificateKeyPassword
Alain Mazy <alain@mazy.be>
parents: 4119
diff changeset
166 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
167 }
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
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 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
170 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
171 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
172 }
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
173
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
174 const std::string &WebServiceParameters::GetCertificateFile() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
175 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
176 return certificateFile_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
177 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
178
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
179 const std::string &WebServiceParameters::GetCertificateKeyFile() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
180 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
181 return certificateKeyFile_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
182 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
183
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
184 const std::string &WebServiceParameters::GetCertificateKeyPassword() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
185 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
186 return certificateKeyPassword_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
187 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
188
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
189 void WebServiceParameters::SetPkcs11Enabled(bool enabled)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
190 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
191 pkcs11Enabled_ = enabled;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
192 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
193
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
194 bool WebServiceParameters::IsPkcs11Enabled() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
195 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
196 return pkcs11Enabled_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
197 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
198
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
199 void WebServiceParameters::AddHttpHeader(const std::string &key, const std::string &value)
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
200 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
201 headers_[key] = value;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
202 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
203
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
204 void WebServiceParameters::ClearHttpHeaders()
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
205 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
206 headers_.clear();
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
207 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
208
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
209 const WebServiceParameters::Dictionary &WebServiceParameters::GetHttpHeaders() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
210 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
211 return headers_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
212 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
213
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
214
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
215 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
216 {
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
217 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
218
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
219 pkcs11Enabled_ = false;
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
220 timeout_ = 0;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
221 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
222
9c9332e486ca HTTPS client certificates can be associated with Orthanc peers to enhance security over Internet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
223 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
224 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
225 {
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 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
227 }
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 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
230
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
231 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
232 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
233 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
234 }
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
235 else if (peer.size() == 2)
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
236 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
237 throw OrthancException(ErrorCode_BadFileFormat,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
238 "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
239 }
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 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
241 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
242 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
243 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
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 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
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 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
248 }
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 }
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
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 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
253 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
254 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
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 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
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 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
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 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
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 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
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 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
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 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
267 }
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
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 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
272 {
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 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
274
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
275 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
276 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
277 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
278 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
279 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
280 else
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
281 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
282 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
283 }
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
284
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
285 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
286 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
287
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
288 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
289 if (!file.empty())
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
290 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
291 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
292 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
293 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
294 else
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
295 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
296 ClearClientCertificate();
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
297 }
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 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
300 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
301 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
302 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
303 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
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 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
306 {
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2021
diff changeset
307 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
308 }
fefbe71c2272 Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2021
diff changeset
309 }
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
310 else
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
311 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
312 pkcs11Enabled_ = false;
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
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
315
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
316 headers_.clear();
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
317
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
318 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
319 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
320 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
321 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
322 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
323 throw OrthancException(ErrorCode_BadFileFormat);
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
324 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
325 else
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
326 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
327 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
328 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
329 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
330 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
331 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
332 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
333 throw OrthancException(ErrorCode_BadFileFormat);
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 else
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 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
338 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
339 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
340 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
341 }
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
342
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 userProperties_.clear();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
345
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
346 const Json::Value::Members members = peer.getMemberNames();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
347
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
348 for (Json::Value::Members::const_iterator it = members.begin();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
349 it != members.end(); ++it)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
350 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
351 if (!IsReservedKey(*it))
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
352 {
3444
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
353 switch (peer[*it].type())
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
354 {
3444
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
355 case Json::stringValue:
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
356 userProperties_[*it] = peer[*it].asString();
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::booleanValue:
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
360 userProperties_[*it] = peer[*it].asBool() ? "1" : "0";
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 case Json::intValue:
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
364 userProperties_[*it] = boost::lexical_cast<std::string>(peer[*it].asInt());
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
365 break;
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
366
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
367 default:
3716
ae0e3fd609df sample for "Manufacturer" option in "DicomModalities" config
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
368 throw OrthancException(ErrorCode_BadFileFormat,
ae0e3fd609df sample for "Manufacturer" option in "DicomModalities" config
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
369 "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
370 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
371 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
372 }
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
373
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
374
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
375 if (peer.isMember(KEY_TIMEOUT))
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
376 {
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
377 timeout_ = SerializationToolbox::ReadUnsignedInteger(peer, KEY_TIMEOUT);
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
378 }
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
379 else
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
380 {
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
381 timeout_ = 0;
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
382 }
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
383 }
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
384
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
385
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
386 void WebServiceParameters::Unserialize(const Json::Value& peer)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 try
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 {
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
390 if (peer.isArray())
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
392 FromSimpleFormat(peer);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 }
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
394 else if (peer.isObject())
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
396 FromAdvancedFormat(peer);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 else
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
2042
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2032
diff changeset
403 catch (OrthancException&)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2032
diff changeset
404 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2032
diff changeset
405 throw;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2032
diff changeset
406 }
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 catch (...)
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 throw OrthancException(ErrorCode_BadFileFormat);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
414 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
415 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
416 target.clear();
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
417
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
418 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
419 it != headers_.end(); ++it)
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 target.insert(it->first);
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 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
424
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 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
427 const std::string& key) const
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 {
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
429 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
430
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
431 if (found == headers_.end())
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
432 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
433 return false;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
434 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
435 else
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
436 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
437 value = found->second;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
438 return true;
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
439 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
440 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
441
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
442
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
443 void WebServiceParameters::AddUserProperty(const std::string& key,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
444 const std::string& value)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
445 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
446 if (IsReservedKey(key))
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
447 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
448 throw OrthancException(
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
449 ErrorCode_ParameterOutOfRange,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
450 "Cannot use this reserved key to name an user property: " + key);
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
451 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
452 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
453 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
454 userProperties_[key] = value;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
455 }
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
4300
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
458 void WebServiceParameters::ClearUserProperties()
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
459 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
460 userProperties_.clear();
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
461 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
462
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
463 const WebServiceParameters::Dictionary &WebServiceParameters::GetUserProperties() const
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
464 {
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
465 return userProperties_;
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
466 }
b30a8de92ad9 abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4194
diff changeset
467
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
468
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
469 void WebServiceParameters::ListUserProperties(std::set<std::string>& target) const
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
470 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
471 target.clear();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
472
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
473 for (Dictionary::const_iterator it = userProperties_.begin();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
474 it != userProperties_.end(); ++it)
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 target.insert(it->first);
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 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
479
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 bool WebServiceParameters::LookupUserProperty(std::string& value,
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
482 const std::string& key) const
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
483 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
484 Dictionary::const_iterator found = userProperties_.find(key);
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
485
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
486 if (found == userProperties_.end())
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
487 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
488 return false;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
489 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
490 else
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
491 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
492 value = found->second;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
493 return true;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
494 }
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
495 }
3444
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
496
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 bool WebServiceParameters::GetBooleanUserProperty(const std::string& key,
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
499 bool defaultValue) const
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 Dictionary::const_iterator found = userProperties_.find(key);
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 if (found == userProperties_.end())
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 return defaultValue;
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
506 }
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
507 else if (found->second == "0" ||
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
508 found->second == "false")
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
509 {
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
510 return false;
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
511 }
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
512 else if (found->second == "1" ||
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
513 found->second == "true")
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
514 {
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
515 return true;
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
516 }
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
517 else
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
518 {
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
519 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
520 "of a Web service: Property \"" + key + "\" equals: " + found->second);
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
521 }
6fe42a335a80 WebServiceParameters::GetBooleanUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3192
diff changeset
522 }
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
523
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
524
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
525 bool WebServiceParameters::IsAdvancedFormatNeeded() const
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
526 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
527 return (!certificateFile_.empty() ||
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
528 !certificateKeyFile_.empty() ||
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
529 !certificateKeyPassword_.empty() ||
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
530 pkcs11Enabled_ ||
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
531 !headers_.empty() ||
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
532 !userProperties_.empty() ||
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
533 timeout_ != 0);
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
534 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
535
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
536
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
537 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
538 bool forceAdvancedFormat,
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
539 bool includePasswords) const
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
540 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
541 if (forceAdvancedFormat ||
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
542 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
543 {
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 value = Json::objectValue;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
545 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
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 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
548 !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
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_USERNAME] = username_;
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
551
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
552 if (includePasswords)
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
553 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
554 value[KEY_PASSWORD] = password_;
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
555 }
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
556 }
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
557
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
558 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
559 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
560 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
561 }
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
562
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
563 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
564 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
565 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
566 }
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
567
2669
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
568 if (!certificateKeyPassword_.empty() &&
eaf10085ffa1 no passwords in public content of jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2659
diff changeset
569 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
570 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
571 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
572 }
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
573
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
574 value[KEY_PKCS11] = pkcs11Enabled_;
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
575 value[KEY_TIMEOUT] = timeout_;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
576
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
577 value[KEY_HTTP_HEADERS] = Json::objectValue;
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
578 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
579 it != headers_.end(); ++it)
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
580 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
581 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
582 }
2823
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
583
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
584 for (Dictionary::const_iterator it = userProperties_.begin();
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
585 it != userProperties_.end(); ++it)
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
586 {
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
587 value[it->first] = it->second;
807169f85ba9 OrthancPluginGetPeerUserProperty()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
588 }
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
589 }
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
590 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
591 {
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
592 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
593 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
594
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
595 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
596 !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
597 {
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
598 value.append(username_);
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
599 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
600 }
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
601 }
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
602 }
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
603
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
604
2779
d67298eec14e fix sandboxing
am@osimis.io
parents: 2669
diff changeset
605 #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
606 void WebServiceParameters::CheckClientCertificate() const
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
607 {
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
608 if (!certificateFile_.empty())
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
609 {
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
610 if (!SystemToolbox::IsRegularFile(certificateFile_))
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
611 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
612 throw OrthancException(ErrorCode_InexistentFile,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
613 "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
614 }
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
615
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
616 if (!certificateKeyFile_.empty() &&
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
617 !SystemToolbox::IsRegularFile(certificateKeyFile_))
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2779
diff changeset
618 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
619 throw OrthancException(ErrorCode_InexistentFile,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2823
diff changeset
620 "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
621 }
2659
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
622 }
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
623 }
2779
d67298eec14e fix sandboxing
am@osimis.io
parents: 2669
diff changeset
624 #endif
3192
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
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
627 void WebServiceParameters::FormatPublic(Json::Value& target) const
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
628 {
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
629 target = Json::objectValue;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
630
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
631 // 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
632 // "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
633 // headers are shown as "null" values.
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
634 target[KEY_URL] = url_;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
635
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
636 if (!username_.empty())
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
637 {
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
638 target[KEY_USERNAME] = username_;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
639 target[KEY_PASSWORD] = Json::nullValue;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
640 }
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
641
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
642 if (!certificateFile_.empty())
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_CERTIFICATE_FILE] = certificateFile_;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
645 target[KEY_CERTIFICATE_KEY_FILE] = Json::nullValue;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
646 target[KEY_CERTIFICATE_KEY_PASSWORD] = Json::nullValue;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
647 }
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[KEY_PKCS11] = pkcs11Enabled_;
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
650 target[KEY_TIMEOUT] = timeout_;
3192
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
651
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
652 Json::Value headers = Json::arrayValue;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
653
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
654 for (Dictionary::const_iterator it = headers_.begin();
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
655 it != headers_.end(); ++it)
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
656 {
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
657 // 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
658 headers.append(it->first);
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
659 }
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
660
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
661 target[KEY_HTTP_HEADERS] = headers;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
662
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
663 for (Dictionary::const_iterator it = userProperties_.begin();
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
664 it != userProperties_.end(); ++it)
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
665 {
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
666 target[it->first] = it->second;
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
667 }
595bfee4391a URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
668 }
4522
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
669
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
670
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
671 void WebServiceParameters::SetTimeout(uint32_t seconds)
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
672 {
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
673 timeout_ = seconds;
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
674 }
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
675
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
676 uint32_t WebServiceParameters::GetTimeout() const
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
677 {
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
678 return timeout_;
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
679 }
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
680
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
681 bool WebServiceParameters::HasTimeout() const
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
682 {
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
683 return (timeout_ != 0);
017ab543e6ef added field "Timeout" in "OrthancPeers" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
684 }
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 }