Skip to content

Commit 021448d

Browse files
committed
feat: add reason of signature
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 50d763f commit 021448d

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

lib/Handler/JSignPdfHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ private function signWrapper(JSignPDF $jSignPDF): string {
144144
$param
145145
->setJSignParameters(
146146
$this->jSignParam->getJSignParameters() .
147-
' --hash-algorithm ' . $this->getHashAlgorithm()
147+
' --hash-algorithm ' . $this->getHashAlgorithm() .
148+
(
149+
$this->getReason()
150+
? ' --reason "' . $this->getReason() . '"'
151+
: ''
152+
)
148153
);
149154
$jSignPDF->setParam($param);
150155
return $jSignPDF->sign();

lib/Handler/Pkcs12Handler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ public function sign(): File {
423423
->setInputFile($this->getInputFile())
424424
->setPassword($this->getPassword())
425425
->setVisibleElements($this->getVisibleElements())
426+
->setReason($this->getReason())
426427
->sign();
427428
$this->getInputFile()->putContent($signedContent);
428429
return $this->getInputFile();

lib/Handler/SignEngineHandler.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ abstract class SignEngineHandler implements ISignEngineHandler {
1515
private File $inputFile;
1616
private string $certificate;
1717
private string $password = '';
18+
private string $reason = '';
1819
/** @var VisibleElementAssoc[] */
1920
private array $visibleElements = [];
2021

@@ -54,6 +55,15 @@ public function getPassword(): string {
5455
return $this->password;
5556
}
5657

58+
public function setReason(string $reason): self {
59+
$this->reason = $reason;
60+
return $this;
61+
}
62+
63+
public function getReason(): string {
64+
return $this->reason;
65+
}
66+
5767
/**
5868
* @param VisibleElementAssoc[] $visibleElements
5969
*

lib/Service/SignFileService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ public function sign(): File {
266266
->setCertificate($pfxFileContent)
267267
->setVisibleElements($this->elements)
268268
->setPassword($this->password)
269+
->setReason($this->l10n->t('Signed by %s with LibreSign.coop', [
270+
$this->signRequest->getDisplayName() . ' <' . $this->userUniqueIdentifier . '>'
271+
]))
269272
->sign();
270273
break;
271274
default:

0 commit comments

Comments
 (0)