From 9ac3b138c6b307097f45dd1c9555b5ed5ec89193 Mon Sep 17 00:00:00 2001
From: Carsten Karbach <c.karbach@fz-juelich.de>
Date: Mon, 6 Nov 2017 11:34:41 +0100
Subject: [PATCH] Add certificate support for event sending

---
 composer.lock           | 12 ++++++------
 lib/EventManagement.php | 15 ++++++++++++++-
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/composer.lock b/composer.lock
index 40fa48d..d56df7a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -8,16 +8,16 @@
     "packages": [
         {
             "name": "jards/eventsapiclient",
-            "version": "v2.1",
+            "version": "v2.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/CarstenKarbach/EventsAPIClient.git",
-                "reference": "884557aea5a532a28340b4ae31b1b82992eb89e3"
+                "reference": "69d8a58854ea6a7cd822a568ba3b6aab70719f7d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/CarstenKarbach/EventsAPIClient/zipball/884557aea5a532a28340b4ae31b1b82992eb89e3",
-                "reference": "884557aea5a532a28340b4ae31b1b82992eb89e3",
+                "url": "https://api.github.com/repos/CarstenKarbach/EventsAPIClient/zipball/69d8a58854ea6a7cd822a568ba3b6aab70719f7d",
+                "reference": "69d8a58854ea6a7cd822a568ba3b6aab70719f7d",
                 "shasum": ""
             },
             "require": {
@@ -60,10 +60,10 @@
                 "swagger"
             ],
             "support": {
-                "source": "https://github.com/CarstenKarbach/EventsAPIClient/tree/v2.1",
+                "source": "https://github.com/CarstenKarbach/EventsAPIClient/tree/v2.2",
                 "issues": "https://github.com/CarstenKarbach/EventsAPIClient/issues"
             },
-            "time": "2017-10-29T15:19:25+00:00"
+            "time": "2017-11-06T10:22:24+00:00"
         },
         {
             "name": "phpmailer/phpmailer",
diff --git a/lib/EventManagement.php b/lib/EventManagement.php
index 4b215fa..c8f404c 100644
--- a/lib/EventManagement.php
+++ b/lib/EventManagement.php
@@ -160,15 +160,28 @@ class EventManagement{
 	 * @param string $name name of the event
 	 * @param string $description description of the event
 	 * @param string $baseURL the root URL of the event receiver REST API
+	 * @param string $certFile path to certificate file to use or null to call URL without certificate
+	 * @param string $certKey path to certificate key file, null to avoid usage of key
+	 * @param string $certPassphrase path to passphrase file for key file, null for no passphrase
 	 * 
 	 * @return boolean true on success, false on error
 	 */
-	public function sendEvent($name, $description, $baseURL='http://localhost/myapps/EventsAPI/rest/events'){
+	public function sendEvent($name, $description, $baseURL='http://localhost/myapps/EventsAPI/rest/events', $certFile = null, $certKey = null, $certPassphrase = null){
 		
 		date_default_timezone_set ( 'Europe/Amsterdam' );
 		$apiClient = new \Swagger\Client\ApiClient ();
 		$apiClient->getConfig ()->setHost ( $baseURL );
 		
+		if(! empty($certFile)){
+			$apiClient->getConfig ()->setCertificate($certFile);
+		}
+		if(! empty($certKey)){
+			$apiClient->getConfig ()->setCertificateKey($certKey);
+		}
+		if(! empty($certPassphrase)){
+			$apiClient->getConfig ()->setCertificatePassphrase($certPassphrase);
+		}
+		
 		$eventsApi = new EventsApi($apiClient);
 		
 		$event = new Event();
-- 
GitLab