From 2a8b61c07fe60d031d0af852c045b52dbbfbeac7 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 11 May 2022 18:29:10 +0200 Subject: [PATCH] - Added new library application/libraries/SignatureLib.php - Changed configs for the signature server in config/vilesci.config-default.inc.php - Changed include/dokument_export.class.php to make use of the new configs --- application/libraries/SignatureLib.php | 76 ++++++++++++++++++++++++++ config/vilesci.config-default.inc.php | 11 +++- include/dokument_export.class.php | 2 +- 3 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 application/libraries/SignatureLib.php diff --git a/application/libraries/SignatureLib.php b/application/libraries/SignatureLib.php new file mode 100644 index 000000000..b8c4374a3 --- /dev/null +++ b/application/libraries/SignatureLib.php @@ -0,0 +1,76 @@ +sendsJson() + ->authenticateWith(SIGNATUR_USER, SIGNATUR_PASSWORD) + ->body('{"filename": "'.basename($inputFileName).'", "content": "'.base64_encode($inputFileContent).'"}') + ->expectsJson() + ->send(); + } + } + catch(\Httpful\Exception\ConnectionErrorException $cee) // Httpful exception + { + $resultList = $cee->getMessage(); + } + catch (Exception $e) // any other exception + { + $resultList = $e->getMessage(); + } + + // If the response is fine + if (isset($resultPost->body) && is_object($resultPost->body) && isset($resultPost->body->retval)) + { + return $resultPost->body->retval; + } + + return $resultList; + } +} + diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index 5285eef3b..a3e4cbece 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -186,11 +186,16 @@ define('FHC_REST_PASSWORD', 'password'); * Signatur * DEFAULT: https://signatur.example.com/api/sign */ -define('SIGNATUR_URL', 'https://signatur.example.com/api/sign'); +// Generic URL +define('SIGNATUR_URL', 'https://signatur.dev.technikum-wien.at/api'); +// Sign API +define('SIGNATUR_SIGN_API', 'sign'); +// List API +define('SIGNATUR_LIST_API', 'list'); // User für Zugriff auf Signaturserver -define('SIGNATUR_USER', 'username'); +define('SIGNATUR_USER', 'fhcomplete'); // Passwort für Zugriff auf Signaturserver -define('SIGNATUR_PASSWORD', 'password'); +define('SIGNATUR_PASSWORD', 'Fhcomplet3Signature!'); // Signaturprofil das verwendet werden soll define('SIGNATUR_DEFAULT_PROFILE', 'FHC_AMT_GROSS_DE'); diff --git a/include/dokument_export.class.php b/include/dokument_export.class.php index 4f23a7dcd..3a6e57657 100644 --- a/include/dokument_export.class.php +++ b/include/dokument_export.class.php @@ -527,7 +527,7 @@ class dokument_export $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL); + curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL.'/'.SIGNATUR_SIGN_API); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7); curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete");