comparison Framework/Orthanc/Core/WebServiceParameters.cpp @ 15:da2cf3ace87a

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 17:20:44 +0100
parents 2dbe613f6c93
children
comparison
equal deleted inserted replaced
14:0b9034112fde 15:da2cf3ace87a
35 35
36 #include "../Core/Logging.h" 36 #include "../Core/Logging.h"
37 #include "../Core/Toolbox.h" 37 #include "../Core/Toolbox.h"
38 #include "../Core/OrthancException.h" 38 #include "../Core/OrthancException.h"
39 39
40 #if ORTHANC_SANDBOXED == 0
41 # include "../Core/SystemToolbox.h"
42 #endif
43
40 #include <cassert> 44 #include <cassert>
41 45
42 namespace Orthanc 46 namespace Orthanc
43 { 47 {
44 WebServiceParameters::WebServiceParameters() : 48 WebServiceParameters::WebServiceParameters() :
55 certificateKeyFile_.clear(); 59 certificateKeyFile_.clear();
56 certificateKeyPassword_.clear(); 60 certificateKeyPassword_.clear();
57 } 61 }
58 62
59 63
64 #if ORTHANC_SANDBOXED == 0
60 void WebServiceParameters::SetClientCertificate(const std::string& certificateFile, 65 void WebServiceParameters::SetClientCertificate(const std::string& certificateFile,
61 const std::string& certificateKeyFile, 66 const std::string& certificateKeyFile,
62 const std::string& certificateKeyPassword) 67 const std::string& certificateKeyPassword)
63 { 68 {
64 if (certificateFile.empty()) 69 if (certificateFile.empty())
65 { 70 {
66 throw OrthancException(ErrorCode_ParameterOutOfRange); 71 throw OrthancException(ErrorCode_ParameterOutOfRange);
67 } 72 }
68 73
69 if (!Toolbox::IsRegularFile(certificateFile)) 74 if (!SystemToolbox::IsRegularFile(certificateFile))
70 { 75 {
71 LOG(ERROR) << "Cannot open certificate file: " << certificateFile; 76 LOG(ERROR) << "Cannot open certificate file: " << certificateFile;
72 throw OrthancException(ErrorCode_InexistentFile); 77 throw OrthancException(ErrorCode_InexistentFile);
73 } 78 }
74 79
75 if (!certificateKeyFile.empty() && 80 if (!certificateKeyFile.empty() &&
76 !Toolbox::IsRegularFile(certificateKeyFile)) 81 !SystemToolbox::IsRegularFile(certificateKeyFile))
77 { 82 {
78 LOG(ERROR) << "Cannot open key file: " << certificateKeyFile; 83 LOG(ERROR) << "Cannot open key file: " << certificateKeyFile;
79 throw OrthancException(ErrorCode_InexistentFile); 84 throw OrthancException(ErrorCode_InexistentFile);
80 } 85 }
81 86
82 advancedFormat_ = true; 87 advancedFormat_ = true;
83 certificateFile_ = certificateFile; 88 certificateFile_ = certificateFile;
84 certificateKeyFile_ = certificateKeyFile; 89 certificateKeyFile_ = certificateKeyFile;
85 certificateKeyPassword_ = certificateKeyPassword; 90 certificateKeyPassword_ = certificateKeyPassword;
86 } 91 }
92 #endif
87 93
88 94
89 static void AddTrailingSlash(std::string& url) 95 static void AddTrailingSlash(std::string& url)
90 { 96 {
91 if (url.size() != 0 && 97 if (url.size() != 0 &&
169 SetUrl(url); 175 SetUrl(url);
170 176
171 SetUsername(GetStringMember(peer, "Username", "")); 177 SetUsername(GetStringMember(peer, "Username", ""));
172 SetPassword(GetStringMember(peer, "Password", "")); 178 SetPassword(GetStringMember(peer, "Password", ""));
173 179
180 #if ORTHANC_SANDBOXED == 0
174 if (peer.isMember("CertificateFile")) 181 if (peer.isMember("CertificateFile"))
175 { 182 {
176 SetClientCertificate(GetStringMember(peer, "CertificateFile", ""), 183 SetClientCertificate(GetStringMember(peer, "CertificateFile", ""),
177 GetStringMember(peer, "CertificateKeyFile", ""), 184 GetStringMember(peer, "CertificateKeyFile", ""),
178 GetStringMember(peer, "CertificateKeyPassword", "")); 185 GetStringMember(peer, "CertificateKeyPassword", ""));
179 } 186 }
187 #endif
180 188
181 if (peer.isMember("Pkcs11")) 189 if (peer.isMember("Pkcs11"))
182 { 190 {
183 if (peer["Pkcs11"].type() == Json::booleanValue) 191 if (peer["Pkcs11"].type() == Json::booleanValue)
184 { 192 {