-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathSignEngineHandler.php
More file actions
103 lines (85 loc) · 2.22 KB
/
SignEngineHandler.php
File metadata and controls
103 lines (85 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Handler\SignEngine;
use OCA\Libresign\DataObjects\VisibleElementAssoc;
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
use OCP\Files\File;
abstract class SignEngineHandler implements ISignEngineHandler {
private File $inputFile;
protected string $certificate;
private string $password = '';
private string $reason = '';
/** @var VisibleElementAssoc[] */
private array $visibleElements = [];
private array $signatureParams = [];
/**
* @return static
*/
public function setInputFile(File $inputFile): self {
$this->inputFile = $inputFile;
return $this;
}
public function getInputFile(): File {
return $this->inputFile;
}
public function setCertificate(string $certificate): self {
$this->certificate = $certificate;
return $this;
}
public function getCertificate(): string {
return $this->certificate;
}
public function readCertificate(): array {
return \OCP\Server::get(CertificateEngineFactory::class)
->getEngine()
->readCertificate(
$this->getCertificate(),
$this->getPassword()
);
}
public function setPassword(string $password): self {
$this->password = $password;
return $this;
}
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
*
* @return static
*/
public function setVisibleElements(array $visibleElements): self {
$this->visibleElements = $visibleElements;
return $this;
}
/**
* @return VisibleElementAssoc[]
*
* @psalm-return array<VisibleElementAssoc>
*/
public function getVisibleElements(): array {
return $this->visibleElements;
}
public function getSignedContent(): string {
return $this->sign()->getContent();
}
public function getSignatureParams(): array {
return $this->signatureParams;
}
public function setSignatureParams(array $params): self {
$this->signatureParams = $params;
return $this;
}
}