diff Core/WebServiceParameters.cpp @ 2022:fefbe71c2272

Possibility to use PKCS#11 authentication for hardware security modules with Orthanc peers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 17 Jun 2016 17:09:50 +0200
parents bd143a77eb7a
children 65b1ce7cb84f
line wrap: on
line diff
--- a/Core/WebServiceParameters.cpp	Wed Jun 15 17:20:52 2016 +0200
+++ b/Core/WebServiceParameters.cpp	Fri Jun 17 17:09:50 2016 +0200
@@ -43,11 +43,20 @@
 {
   WebServiceParameters::WebServiceParameters() : 
     advancedFormat_(false),
-    url_("http://localhost:8042/")
+    url_("http://localhost:8042/"),
+    pkcs11Enabled_(false)
   {
   }
 
 
+  void WebServiceParameters::ClearClientCertificate()
+  {
+    certificateFile_.clear();
+    certificateKeyFile_.clear();
+    certificateKeyPassword_.clear();
+  }
+
+
   void WebServiceParameters::SetClientCertificate(const std::string& certificateFile,
                                                   const std::string& certificateKeyFile,
                                                   const std::string& certificateKeyPassword)
@@ -92,6 +101,7 @@
     assert(peer.isArray());
 
     advancedFormat_ = false;
+    pkcs11Enabled_ = false;
 
     if (peer.size() != 1 && 
         peer.size() != 3)
@@ -167,6 +177,18 @@
                            GetStringMember(peer, "CertificateKeyFile", ""),
                            GetStringMember(peer, "CertificateKeyPassword", ""));
     }
+
+    if (peer.isMember("Pkcs11"))
+    {
+      if (peer["Pkcs11"].type() == Json::booleanValue)
+      {
+        pkcs11Enabled_ = peer["Pkcs11"].asBool();
+      }
+      else
+      {
+        throw OrthancException(ErrorCode_BadFileFormat);
+      }
+    }
   }