File tree Expand file tree Collapse file tree 5 files changed +23
-14
lines changed
Expand file tree Collapse file tree 5 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,6 @@ public function setPassword(string $password): self;
1919 public function getPassword (): string ;
2020 public function sign (): File ;
2121 public function getSignedContent (): string ;
22- public function getSignatureText (): string ;
23- public function setSignatureText ( string $ text ): self ;
22+ public function getSignatureParams (): array ;
23+ public function setSignatureParams ( array $ params ): self ;
2424}
Original file line number Diff line number Diff line change 1313use OCA \Libresign \AppInfo \Application ;
1414use OCA \Libresign \Exception \LibresignException ;
1515use OCA \Libresign \Service \Install \InstallService ;
16+ use OCA \Libresign \Service \SignatureTextService ;
1617use OCP \Files \File ;
1718use OCP \IAppConfig ;
1819use Psr \Log \LoggerInterface ;
@@ -26,6 +27,7 @@ class JSignPdfHandler extends SignEngineHandler {
2627 public function __construct (
2728 private IAppConfig $ appConfig ,
2829 private LoggerInterface $ logger ,
30+ private SignatureTextService $ signatureTextService ,
2931 ) {
3032 }
3133
@@ -146,7 +148,17 @@ private function signUsingVisibleElements(): string {
146148
147149 public function getSignatureText (): string {
148150 $ signatureText = parent ::getSignatureText ();
149- $ signatureText = '" ' . str_replace ('" ' , '\" ' , $ signatureText ) . '" ' ;
151+ $ params = $ this ->getSignatureParams ();
152+ $ params ['SignerName ' ] = '${signer} ' ;
153+ $ params ['SignatureDate ' ] = '${timestamp} ' ;
154+ $ this ->signatureTextService ->parse (context: $ params );
155+
156+ $ signatureText = '" ' . str_replace (
157+ ['" ' , '$ ' ],
158+ ['\" ' , '\$ ' ],
159+ $ signatureText
160+ ) . '" ' ;
161+
150162 return $ signatureText ;
151163 }
152164
Original file line number Diff line number Diff line change @@ -422,7 +422,7 @@ public function sign(): File {
422422 ->setCertificate ($ this ->getCertificate ())
423423 ->setInputFile ($ this ->getInputFile ())
424424 ->setPassword ($ this ->getPassword ())
425- ->setSignatureText ($ this ->getSignatureText ())
425+ ->setSignatureParams ($ this ->getSignatureParams ())
426426 ->setVisibleElements ($ this ->getVisibleElements ())
427427 ->getSignedContent ();
428428 $ this ->getInputFile ()->putContent ($ signedContent );
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ abstract class SignEngineHandler implements ISignEngineHandler {
1717 private string $ password = '' ;
1818 /** @var VisibleElementAssoc[] */
1919 private array $ visibleElements = [];
20- private string $ signatureText = '' ;
20+ private array $ signatureParams = [] ;
2121
2222 /**
2323 * @return static
@@ -72,12 +72,12 @@ public function getSignedContent(): string {
7272 return $ this ->sign ()->getContent ();
7373 }
7474
75- public function getSignatureText (): string {
76- return $ this ->signatureText ;
75+ public function getSignatureParams (): array {
76+ return $ this ->signatureParams ;
7777 }
7878
79- public function setSignatureText ( string $ text ): self {
80- $ this ->signatureText = $ text ;
79+ public function setSignatureParams ( array $ params ): self {
80+ $ this ->signatureParams = $ params ;
8181 return $ this ;
8282 }
8383}
Original file line number Diff line number Diff line change @@ -97,7 +97,6 @@ public function __construct(
9797 private ITempManager $ tempManager ,
9898 private IdentifyMethodService $ identifyMethodService ,
9999 private ITimeFactory $ timeFactory ,
100- private SignatureTextService $ signatureTextService ,
101100 ) {
102101 }
103102
@@ -270,12 +269,10 @@ public function sign(): File {
270269 ->setCertificate ($ pfxFileContent )
271270 ->setVisibleElements ($ this ->elements )
272271 ->setPassword ($ this ->password )
273- ->setSignatureText ($ this ->signatureTextService ->parse (context: [
274- 'SignerName ' => '\${signer} ' ,
272+ ->setSignatureParams ([
275273 'DocumentUUID ' => $ this ->libreSignFile ->getUuid (),
276274 'IssuerCommonName ' => $ pfxData ['issuer ' ]['CN ' ],
277- 'SignatureDate ' => '\${timestamp} ' ,
278- ]))
275+ ])
279276 ->sign ();
280277 break ;
281278 default :
You can’t perform that action at this time.
0 commit comments