Skip to content

Commit

Permalink
feat: add reason of signature
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <vitor@php.rio>
  • Loading branch information
vitormattos committed Feb 1, 2025
1 parent ef7cf8c commit 7fac5d8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Handler/JSignPdfHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ private function signWrapper(JSignPDF $jSignPDF): string {
$param
->setJSignParameters(
$this->jSignParam->getJSignParameters() .
' --hash-algorithm ' . $this->getHashAlgorithm()
' --hash-algorithm ' . $this->getHashAlgorithm() .
(
$this->getReason()
? ' --reason "' . $this->getReason() . '"'
: ''
)
);
$jSignPDF->setParam($param);
return $jSignPDF->sign();
Expand Down
1 change: 1 addition & 0 deletions lib/Handler/Pkcs12Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ public function sign(): File {
->setInputFile($this->getInputFile())
->setPassword($this->getPassword())
->setVisibleElements($this->getvisibleElements())
->setReason($this->getReason())
->sign();
$this->getInputFile()->putContent($signedContent);
return $this->getInputFile();
Expand Down
10 changes: 10 additions & 0 deletions lib/Handler/SignEngineHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class SignEngineHandler implements ISignEngineHandler {
private File $inputFile;
private string $certificate;
private string $password = '';
private string $reason = '';
/** @var VisibleElementAssoc[] */
private array $visibleElements = [];

Expand Down Expand Up @@ -54,6 +55,15 @@ public function getPassword(): string {
return $this->password;
}

public function setReason(string $reason): self {
$this->reason = $reason;
return $this;
}

public function getReason(): string {
return $this->reason;
}

/**
* @param VisibleElementAssoc[] $visibleElements
*
Expand Down
3 changes: 3 additions & 0 deletions lib/Service/SignFileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ public function sign(): File {
->setCertificate($pfxFileContent)
->setVisibleElements($this->elements)
->setPassword($this->password)
->setReason($this->l10n->t('Signed by %s with LibreSign.coop', [
$this->signRequest->getDisplayName() . ' <' . $this->userUniqueIdentifier . '>'
]))
->sign();
break;
default:
Expand Down

0 comments on commit 7fac5d8

Please sign in to comment.