mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-14 10:39:27 +00:00
- 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
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2022 fhcomplete.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../../vendor/nategood/httpful/bootstrap.php');
|
||||
|
||||
/**
|
||||
* Simple client to call the signature server
|
||||
*/
|
||||
class SignatureLib
|
||||
{
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// Public static methods
|
||||
|
||||
/**
|
||||
* Returns the list of signature inside the given file
|
||||
*/
|
||||
public static function list($inputFileName)
|
||||
{
|
||||
// Generic error occurred
|
||||
$resultList = 'Generic error occurred';
|
||||
|
||||
try
|
||||
{
|
||||
// Get the content of the given file
|
||||
$inputFileContent = file_get_contents($inputFileName);
|
||||
if ($inputFileContent === false) // if failed
|
||||
{
|
||||
$resultList = 'An error occurred while getting the content from: '.$inputFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Posts the given file content + file name and expects a response in JSON format
|
||||
$resultPost = \Httpful\Request::post(SIGNATUR_URL.'/'.SIGNATUR_LIST_API)
|
||||
->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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user