-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJSignParam.php
More file actions
186 lines (154 loc) · 4.44 KB
/
JSignParam.php
File metadata and controls
186 lines (154 loc) · 4.44 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
namespace Jeidison\JSignPDF\Sign;
/**
* @author Jeidison Farias <[email protected]>
*/
class JSignParam
{
private $pdf;
private $certificate;
private $password;
private $pathPdfSigned;
private $JSignParameters = "-a -kst PKCS12";
private $isUseJavaInstalled = false;
private string $javaPath = '';
private $tempPath;
private $tempName;
private $isOutputTypeBase64 = false;
private string $jSignPdfJarPath;
private string $javaDownloadUrl = 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.8%2B9/OpenJDK21U-jre_x64_linux_hotspot_21.0.8_9.tar.gz';
private string $jSignPdfDownloadUrl = 'https://github.com/intoolswetrust/jsignpdf/releases/download/JSignPdf_2_3_0/jsignpdf-2.3.0.zip';
public function __construct()
{
$this->tempName = md5(time() . uniqid() . mt_rand());
$this->tempPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR;
$this->javaPath = $this->tempPath . 'java' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'java';
$this->jSignPdfJarPath = $this->tempPath . 'jsignpdf' . DIRECTORY_SEPARATOR . 'JSignPdf.jar';
}
public static function instance()
{
return new self();
}
public function getPdf()
{
return $this->pdf;
}
public function setPdf($pdf)
{
$this->pdf = $pdf;
return $this;
}
public function getCertificate()
{
return $this->certificate;
}
public function setCertificate($certificate)
{
$this->certificate = $certificate;
return $this;
}
public function getPassword()
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
return $this;
}
public function getPathPdfSigned()
{
return $this->pathPdfSigned != null ? $this->pathPdfSigned : $this->getTempPath();
}
public function setPathPdfSigned($pathPdfSigned)
{
$this->pathPdfSigned = $pathPdfSigned;
return $this;
}
public function getJSignParameters(): string
{
return $this->JSignParameters;
}
public function setJSignParameters(string $JSignParameters)
{
$this->JSignParameters = $JSignParameters;
return $this;
}
public function getTempPath()
{
return $this->tempPath;
}
public function setTempPath($tempPath)
{
$this->tempPath = $tempPath;
return $this;
}
public function getTempName($extension = null)
{
return $this->tempName.$extension;
}
public function isUseJavaInstalled(): bool
{
return $this->isUseJavaInstalled;
}
public function setIsUseJavaInstalled(bool $isUseJavaInstalled)
{
$this->isUseJavaInstalled = $isUseJavaInstalled;
return $this;
}
public function setJavaPath($javaPath): self {
$this->javaPath = $javaPath;
return $this;
}
public function getJavaPath(): string {
return $this->javaPath;
}
public function setjSignPdfJarPath($jSignPdfJarPath)
{
$this->jSignPdfJarPath = $jSignPdfJarPath;
return $this;
}
public function getjSignPdfJarPath()
{
return $this->jSignPdfJarPath;
}
public function isOutputTypeBase64(): bool
{
return $this->isOutputTypeBase64;
}
public function setIsOutputTypeBase64(bool $isOutputTypeBase64)
{
$this->isOutputTypeBase64 = $isOutputTypeBase64;
return $this;
}
public function getTempPdfPath()
{
return $this->getTempPath() . $this->getTempName('.pdf');
}
public function getTempPdfSignedPath()
{
return $this->getPathPdfSigned() . $this->getTempName('_signed.pdf');
}
public function getTempCertificatePath()
{
return $this->getTempPath() . $this->getTempName('.pfx');
}
public function setJavaDownloadUrl(string $url): self
{
$this->javaDownloadUrl = $url;
return $this;
}
public function getJavaDownloadUrl(): string
{
return $this->javaDownloadUrl;
}
public function setJSignPdfDownloadUrl(string $url): self
{
$this->jSignPdfDownloadUrl = $url;
return $this;
}
public function getJSignPdfDownloadUrl(): string
{
return $this->jSignPdfDownloadUrl;
}
}