Mercurial > hg > orthanc
comparison Core/WebServiceParameters.cpp @ 2669:eaf10085ffa1 jobs
no passwords in public content of jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 09 Jun 2018 14:15:32 +0200 |
parents | c27f7ecf9b54 |
children | d67298eec14e |
comparison
equal
deleted
inserted
replaced
2668:d26dd081df97 | 2669:eaf10085ffa1 |
---|---|
128 if (peer.size() == 1) | 128 if (peer.size() == 1) |
129 { | 129 { |
130 SetUsername(""); | 130 SetUsername(""); |
131 SetPassword(""); | 131 SetPassword(""); |
132 } | 132 } |
133 else if (peer.size() == 2) | |
134 { | |
135 LOG(ERROR) << "The HTTP password is not provided"; | |
136 throw OrthancException(ErrorCode_BadFileFormat); | |
137 } | |
133 else if (peer.size() == 3) | 138 else if (peer.size() == 3) |
134 { | 139 { |
135 SetUsername(peer.get(1u, "").asString()); | 140 SetUsername(peer.get(1u, "").asString()); |
136 SetPassword(peer.get(2u, "").asString()); | 141 SetPassword(peer.get(2u, "").asString()); |
137 } | 142 } |
176 SetUrl(url); | 181 SetUrl(url); |
177 | 182 |
178 SetUsername(GetStringMember(peer, "Username", "")); | 183 SetUsername(GetStringMember(peer, "Username", "")); |
179 SetPassword(GetStringMember(peer, "Password", "")); | 184 SetPassword(GetStringMember(peer, "Password", "")); |
180 | 185 |
186 if (!username_.empty() && | |
187 !peer.isMember("Password")) | |
188 { | |
189 LOG(ERROR) << "The HTTP password is not provided"; | |
190 throw OrthancException(ErrorCode_BadFileFormat); | |
191 } | |
192 | |
181 #if ORTHANC_SANDBOXED == 0 | 193 #if ORTHANC_SANDBOXED == 0 |
182 if (peer.isMember("CertificateFile")) | 194 if (peer.isMember("CertificateFile")) |
183 { | 195 { |
184 SetClientCertificate(GetStringMember(peer, "CertificateFile", ""), | 196 SetClientCertificate(GetStringMember(peer, "CertificateFile", ""), |
185 GetStringMember(peer, "CertificateKeyFile", ""), | 197 GetStringMember(peer, "CertificateKeyFile", ""), |
186 GetStringMember(peer, "CertificateKeyPassword", "")); | 198 GetStringMember(peer, "CertificateKeyPassword", "")); |
199 | |
200 if (!peer.isMember("CertificateKeyPassword")) | |
201 { | |
202 LOG(ERROR) << "The password for the HTTPS certificate is not provided"; | |
203 throw OrthancException(ErrorCode_BadFileFormat); | |
204 } | |
187 } | 205 } |
188 #endif | 206 #endif |
189 | 207 |
190 if (peer.isMember("Pkcs11")) | 208 if (peer.isMember("Pkcs11")) |
191 { | 209 { |
227 throw OrthancException(ErrorCode_BadFileFormat); | 245 throw OrthancException(ErrorCode_BadFileFormat); |
228 } | 246 } |
229 } | 247 } |
230 | 248 |
231 | 249 |
232 void WebServiceParameters::ToJson(Json::Value& value) const | 250 void WebServiceParameters::ToJson(Json::Value& value, |
251 bool includePasswords) const | |
233 { | 252 { |
234 if (advancedFormat_) | 253 if (advancedFormat_) |
235 { | 254 { |
236 value = Json::objectValue; | 255 value = Json::objectValue; |
237 value["Url"] = url_; | 256 value["Url"] = url_; |
238 | 257 |
239 if (!username_.empty() || | 258 if (!username_.empty() || |
240 !password_.empty()) | 259 !password_.empty()) |
241 { | 260 { |
242 value["Username"] = username_; | 261 value["Username"] = username_; |
243 value["Password"] = password_; | 262 |
263 if (includePasswords) | |
264 { | |
265 value["Password"] = password_; | |
266 } | |
244 } | 267 } |
245 | 268 |
246 if (!certificateFile_.empty()) | 269 if (!certificateFile_.empty()) |
247 { | 270 { |
248 value["CertificateFile"] = certificateFile_; | 271 value["CertificateFile"] = certificateFile_; |
251 if (!certificateKeyFile_.empty()) | 274 if (!certificateKeyFile_.empty()) |
252 { | 275 { |
253 value["CertificateKeyFile"] = certificateKeyFile_; | 276 value["CertificateKeyFile"] = certificateKeyFile_; |
254 } | 277 } |
255 | 278 |
256 if (!certificateKeyPassword_.empty()) | 279 if (!certificateKeyPassword_.empty() && |
280 includePasswords) | |
257 { | 281 { |
258 value["CertificateKeyPassword"] = certificateKeyPassword_; | 282 value["CertificateKeyPassword"] = certificateKeyPassword_; |
259 } | 283 } |
260 } | 284 } |
261 else | 285 else |
265 | 289 |
266 if (!username_.empty() || | 290 if (!username_.empty() || |
267 !password_.empty()) | 291 !password_.empty()) |
268 { | 292 { |
269 value.append(username_); | 293 value.append(username_); |
270 value.append(password_); | 294 |
295 if (includePasswords) | |
296 { | |
297 value.append(password_); | |
298 } | |
271 } | 299 } |
272 } | 300 } |
273 } | 301 } |
274 | 302 |
275 | 303 |
281 target["Password"] = password_; | 309 target["Password"] = password_; |
282 target["CertificateFile"] = certificateFile_; | 310 target["CertificateFile"] = certificateFile_; |
283 target["CertificateKeyFile"] = certificateKeyFile_; | 311 target["CertificateKeyFile"] = certificateKeyFile_; |
284 target["CertificateKeyPassword"] = certificateKeyPassword_; | 312 target["CertificateKeyPassword"] = certificateKeyPassword_; |
285 target["PKCS11"] = pkcs11Enabled_; | 313 target["PKCS11"] = pkcs11Enabled_; |
314 target["AdvancedFormat"] = advancedFormat_; | |
286 } | 315 } |
287 | 316 |
288 | 317 |
289 WebServiceParameters::WebServiceParameters(const Json::Value& serialized) : | 318 WebServiceParameters::WebServiceParameters(const Json::Value& serialized) : |
290 advancedFormat_(true) | 319 advancedFormat_(true) |
302 { | 331 { |
303 SetClientCertificate(a, b, c); | 332 SetClientCertificate(a, b, c); |
304 } | 333 } |
305 | 334 |
306 pkcs11Enabled_ = SerializationToolbox::ReadBoolean(serialized, "PKCS11"); | 335 pkcs11Enabled_ = SerializationToolbox::ReadBoolean(serialized, "PKCS11"); |
336 advancedFormat_ = SerializationToolbox::ReadBoolean(serialized, "AdvancedFormat"); | |
307 } | 337 } |
308 } | 338 } |