diff --git a/config/config.xml.default b/config/config.xml.default index e0c3137c724c0f531b78edafdb2111f2291361f8..1e7c619a1502260b17a21e780d42366a2ec97b60 100755 --- a/config/config.xml.default +++ b/config/config.xml.default @@ -43,17 +43,17 @@ <mode> <id>rgs_2stars</id> <color>#FF0000</color> - <issuer>ChamberSign</issuer> + <issuer></issuer> </mode> <mode> <id>inca_card_eidas</id> <color>#FFA500</color> - <issuer>customer</issuer> + <issuer></issuer> </mode> <mode> <id>inca_card</id> <color>#FFA500</color> - <issuer>customer</issuer> + <issuer></issuer> </mode> <mode> <id>eidas</id> diff --git a/lang/fr.json b/lang/fr.json index 2320c6cfdf7416a5ec35b46b0f48db123a69b272..931d5dad7c7ea08d96ed701f95286068832d73bd 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -336,6 +336,7 @@ "eidas": "Organisation déléguée", "rgs_2stars": "Clé RGS**", "rgs_2stars_timestamped": "Clé RGS** + horodatage", + "docaposteSignatureDisabled": "Le paramètre docaposteSignature n'est pas activé", "noAssociatedGroup": "L'utilisateur n'appartient à aucun groupe", "docToSign": "Document à signer", "attachDocToSign": "Annexe attaché au(x) document(s) à signer", diff --git a/package.json b/package.json index e85487f1742b0d9d0e47d4b94380d901b1419816..b82d1a3470824d4dcef13ee64a67150d2f724f8b 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,10 @@ "zone.js": "~0.10.2" }, "devDependencies": { - "@angular-devkit/build-angular": "^0.1100.3", + "@angular-devkit/build-angular": "^0.1100.4", "@angular/animations": "^11.0.4", "@angular/cdk": "^11.0.2", - "@angular/cli": "^11.0.3", + "@angular/cli": "^11.0.4", "@angular/common": "^11.0.4", "@angular/compiler": "^11.0.4", "@angular/compiler-cli": "^11.0.4", @@ -53,7 +53,7 @@ "@types/jasmine": "^3.6.2", "@types/jasminewd2": "^2.0.8", "@types/jquery": "^3.5.5", - "@types/node": "^13.13.35", + "@types/node": "^13.13.36", "angular2-draggable": "^2.3.2", "angular2-signaturepad": "^2.11.0", "codelyzer": "^5.1.2", diff --git a/src/app/document/controllers/CertificateSignatureController.php b/src/app/document/controllers/CertificateSignatureController.php index da9ca65a4478d657cacef4bcb040d6e53683b42d..ac19b72c36a4c05ed75d051f1cfb51f56ac97086 100755 --- a/src/app/document/controllers/CertificateSignatureController.php +++ b/src/app/document/controllers/CertificateSignatureController.php @@ -35,17 +35,16 @@ class CertificateSignatureController 'data' => [$args['id'], 'ESIGN'] ]); if (!empty($adr)) { - $docserver = DocserverModel::getByType(['type' => 'ESIGN', 'select' => ['path']]); - $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; + $docserver = DocserverModel::getByType(['type' => 'ESIGN', 'select' => ['path']]); } else { $adr = AdrModel::getDocumentsAdr([ 'select' => ['path', 'filename'], 'where' => ['main_document_id = ?', 'type = ?'], 'data' => [$args['id'], 'DOC'] ]); - $docserver = DocserverModel::getByType(['type' => 'DOC', 'select' => ['path']]); - $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; + $docserver = DocserverModel::getByType(['type' => 'DOC', 'select' => ['path']]); } + $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; $tmpPath = CoreConfigModel::getTmpPath(); $signedDocumentPath = $tmpPath . $GLOBALS['id'] . '_' . rand() . '_signedDocument.pdf'; @@ -201,17 +200,16 @@ class CertificateSignatureController 'data' => [$args['id'], 'ESIGN'] ]); if (!empty($adr)) { - $docserver = DocserverModel::getByType(['type' => 'ESIGN', 'select' => ['path']]); - $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; + $docserver = DocserverModel::getByType(['type' => 'ESIGN', 'select' => ['path']]); } else { $adr = AdrModel::getDocumentsAdr([ 'select' => ['path', 'filename'], 'where' => ['main_document_id = ?', 'type = ?'], 'data' => [$args['id'], 'DOC'] ]); - $docserver = DocserverModel::getByType(['type' => 'DOC', 'select' => ['path']]); - $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; + $docserver = DocserverModel::getByType(['type' => 'DOC', 'select' => ['path']]); } + $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; $tmpPath = CoreConfigModel::getTmpPath(); $signedDocumentPath = $tmpPath . $GLOBALS['id'] . '_' . rand() . '_signedDocument.pdf'; $writer = new \SetaPDF_Core_Writer_File($signedDocumentPath); @@ -231,7 +229,7 @@ class CertificateSignatureController return ['errors' => 'Not enough space for signature', 'newSignatureLength' => $signatureContentLength]; } - if (in_array($args['signatureMode'], ['rgs_2stars_timestamped', 'inca_card_eidas'])) { + if ($args['signatureMode'] == 'rgs_2stars_timestamped') { $document = DocumentModel::getById(['select' => ['digital_signature_transaction_id'], 'id' => $args['id']]); $config = DigitalSignatureController::getConfig(); $signedDocumentPath = DigitalSignatureController::timestampHashes([ diff --git a/src/app/document/controllers/DocumentController.php b/src/app/document/controllers/DocumentController.php index 20e0d7b3f5720023a596701cad41de0667ca7a81..487e7d9e7fc069de99d9a5974bab6aa8a12b3dc5 100755 --- a/src/app/document/controllers/DocumentController.php +++ b/src/app/document/controllers/DocumentController.php @@ -518,6 +518,9 @@ class DocumentController } require_once($libDir . 'SetaPDF-Signer/library/SetaPDF/Autoload.php'); } + if (in_array($workflow['signature_mode'], ['eidas', 'inca_card_eidas']) && $loadedXml->docaposteSignature->enable != 'true') { + return $response->withStatus(400)->withJson(['errors' => 'docaposteSignature is disabled', 'lang' => 'docaposteSignatureDisabled']); + } $body = $request->getParsedBody(); if (DocumentController::ACTIONS[$args['actionId']] == 'VAL' && $workflow['signature_mode'] == 'stamp') { @@ -630,35 +633,25 @@ class DocumentController return $response->withJson($hashInformations); } - if ($loadedXml->docaposteSignature->enable == 'true' && $workflow['signature_mode'] == 'eidas') { - if ($workflow['mode'] == 'visa' && !empty($body['signatures'])) { - $adr = AdrModel::getDocumentsAdr([ - 'select' => ['path', 'filename'], - 'where' => ['main_document_id = ?', 'type = ?'], - 'data' => [$args['id'], 'DOC'] - ]); - $docserver = DocserverModel::getByType(['type' => 'DOC', 'select' => ['path']]); - $pathToDocument = $docserver['path'] . $adr[0]['path'] . $adr[0]['filename']; - $storeInfos = DocserverController::storeResourceOnDocServer([ - 'encodedFile' => base64_encode(file_get_contents($pathToDocument)), - 'format' => 'pdf', - 'docserverType' => 'ESIGN' - ]); - if (!empty($storeInfos['errors'])) { - return $response->withStatus(500)->withJson(['errors' => $storeInfos['errors']]); - } - AdrModel::deleteDocumentAdr([ - 'where' => ['main_document_id = ?', 'type = ?'], - 'data' => [$args['id'], 'ESIGN'] - ]); - AdrModel::createDocumentAdr([ - 'documentId' => $args['id'], - 'type' => 'ESIGN', - 'path' => $storeInfos['path'], - 'filename' => $storeInfos['filename'], - 'fingerprint' => $storeInfos['fingerprint'] - ]); - } elseif (DocumentController::ACTIONS[$args['actionId']] == 'VAL' && $workflow['mode'] == 'sign') { + if (in_array($workflow['signature_mode'], ['rgs_2stars', 'rgs_2stars_timestamped', 'inca_card', 'inca_card_eidas'])) { + if (empty($body['hashSignature'])) { + return $response->withStatus(400)->withJson(['errors' => 'Body hashSignature is empty']); + } + $return = CertificateSignatureController::signDocument([ + 'id' => $args['id'], + 'certificate' => $body['certificate'], + 'signatureContentLength' => $body['signatureContentLength'], + 'signatureFieldName' => $body['signatureFieldName'], + 'hashSignature' => $body['hashSignature'], + 'signatureMode' => $workflow['signature_mode'] + ]); + if (!empty($return['errors'])) { + return $response->withStatus(400)->withJson($return); + } + } + + if (in_array($workflow['signature_mode'], ['eidas', 'inca_card_eidas'])) { + if (DocumentController::ACTIONS[$args['actionId']] == 'VAL' && $workflow['mode'] == 'sign') { $imageSignature = false; $adr = AdrModel::getDocumentsAdr([ 'select' => ['path', 'filename'], @@ -705,7 +698,7 @@ class DocumentController $signPosX = ($signature['positionX'] * $format['width']) / 100; $signPosY = ($signature['positionY'] * $format['height']) / 100; } - DigitalSignatureController::signHashes([ + $return = DigitalSignatureController::signHashes([ 'signatureId' => $workflow['digital_signature_id'], 'documentId' => $args['id'], 'signatureInfo' => [ @@ -717,31 +710,25 @@ class DocumentController ], 'isLastSignature' => !isset($body['signatures'][$key + 1]) ]); + if (!empty($return['errors'])) { + return $response->withStatus(400)->withJson($return); + } $imageSignature = true; } } } } if (!$imageSignature) { - DigitalSignatureController::signHashes(['signatureId' => $workflow['digital_signature_id'], 'documentId' => $args['id'], 'isLastSignature' => true]); + $return = DigitalSignatureController::signHashes(['signatureId' => $workflow['digital_signature_id'], 'documentId' => $args['id'], 'isLastSignature' => true]); + if (!empty($return['errors'])) { + return $response->withStatus(400)->withJson($return); + } } } elseif (DocumentController::ACTIONS[$args['actionId']] == 'REF' && $workflow['mode'] == 'sign') { - DigitalSignatureController::abort(['signatureId' => $workflow['digital_signature_id'], 'documentId' => $args['id']]); - } - } elseif (in_array($workflow['signature_mode'], ['rgs_2stars', 'rgs_2stars_timestamped', 'inca_card', 'inca_card_eidas'])) { - if (empty($body['hashSignature'])) { - return $response->withStatus(400)->withJson(['errors' => 'Body hashSignature is empty']); - } - $return = CertificateSignatureController::signDocument([ - 'id' => $args['id'], - 'certificate' => $body['certificate'], - 'signatureContentLength' => $body['signatureContentLength'], - 'signatureFieldName' => $body['signatureFieldName'], - 'hashSignature' => $body['hashSignature'], - 'signatureMode' => $workflow['signature_mode'] - ]); - if (!empty($return['errors'])) { - return $response->withStatus(400)->withJson($return); + $return = DigitalSignatureController::abort(['signatureId' => $workflow['digital_signature_id'], 'documentId' => $args['id']]); + if (!empty($return['errors'])) { + return $response->withStatus(400)->withJson($return); + } } }