55use League \OAuth2 \Client \OptionProvider \OptionProviderInterface ;
66use League \OAuth2 \Client \Provider \AbstractProvider ;
77use League \OAuth2 \Client \Provider \GenericProvider ;
8- use SetaPDF_Signer_Digest as Digest ;
8+ use setasign \ SetaPDF2 \ Signer \ Digest ;
99use setasign \SetaPDF \Signer \Module \CSC \Client ;
1010use setasign \SetaPDF \Signer \Module \CSC \Module ;
11-
12- ini_set ('display_errors ' , '1 ' );
13- ini_set ('display_startup_errors ' , '1 ' );
14- error_reporting (E_ALL );
11+ use setasign \SetaPDF2 \Core \Document ;
12+ use setasign \SetaPDF2 \Core \Reader \FileReader ;
13+ use setasign \SetaPDF2 \Core \Writer \FileWriter ;
14+ use setasign \SetaPDF2 \Core \Writer \StringWriter ;
15+ use setasign \SetaPDF2 \Core \Writer \TempFileWriter ;
16+ use setasign \SetaPDF2 \Signer \DocumentSecurityStore ;
17+ use setasign \SetaPDF2 \Signer \Signature \Module \Pades ;
18+ use setasign \SetaPDF2 \Signer \Signer ;
19+ use setasign \SetaPDF2 \Signer \TmpDocument ;
20+ use setasign \SetaPDF2 \Signer \ValidationRelatedInfo \Collector ;
21+ use setasign \SetaPDF2 \Signer \X509 \Certificate ;
22+ use setasign \SetaPDF2 \Signer \X509 \Collection ;
1523
1624require_once (__DIR__ . '/../vendor/autoload.php ' );
1725
4553$ accessToken = $ _SESSION ['accessToken ' ]['access_token ' ];
4654
4755$ httpClient = new GuzzleHttp \Client ();
48- $ httpClient = new Mjelamanov \GuzzlePsr18 \Client ($ httpClient );
4956$ requestFactory = new Http \Factory \Guzzle \RequestFactory ();
5057$ streamFactory = new Http \Factory \Guzzle \StreamFactory ();
5158$ client = new Client ($ apiUri , $ httpClient , $ requestFactory , $ streamFactory );
@@ -115,8 +122,8 @@ public function getAccessTokenOptions($method, array $params)
115122 }
116123
117124 $ certificates = $ credentialInfo ['cert ' ]['certificates ' ];
118- $ certificates = array_map (function (string $ certificate ) {
119- return new SetaPDF_Signer_X509_Certificate ($ certificate );
125+ $ certificates = array_map (static function (string $ certificate ) {
126+ return new Certificate ($ certificate );
120127 }, $ certificates );
121128 // to cache the certificate files
122129 //foreach ($certificates as $k => $certificate) {
@@ -129,22 +136,22 @@ public function getAccessTokenOptions($method, array $params)
129136 $ signatureAlgorithmOid = $ credentialInfo ['key ' ]['algo ' ][0 ];
130137
131138 // create a writer instance
132- $ writer = new SetaPDF_Core_Writer_File ($ resultPath );
139+ $ writer = new FileWriter ($ resultPath );
133140 // create the document instance
134- $ document = SetaPDF_Core_Document ::loadByFilename ($ fileToSign , $ writer );
141+ $ document = Document ::loadByFilename ($ fileToSign , $ writer );
135142
136143 // create the signer instance
137- $ signer = new SetaPDF_Signer ($ document );
144+ $ signer = new Signer ($ document );
138145
139- $ module = new SetaPDF_Signer_Signature_Module_Pades ();
146+ $ module = new Pades ();
140147 $ module ->setCertificate ($ certificate );
141148 $ module ->setExtraCertificates ($ certificates );
142149
143150 ['hashAlgorithm ' => $ hashAlgorithm , 'signAlgorithm ' => $ signAlgorithm ] = Module::findHashAndSignAlgorithm ($ signatureAlgorithmOid );
144151 $ module ->setDigest ($ hashAlgorithm );
145152
146153 // create a collector instance
147- $ collector = new SetaPDF_Signer_ValidationRelatedInfo_Collector (new SetaPDF_Signer_X509_Collection ($ certificates ));
154+ $ collector = new Collector (new Collection ($ certificates ));
148155 // collect revocation information for this certificate
149156 $ vriData = $ collector ->getByCertificate ($ certificate );
150157
@@ -157,7 +164,7 @@ public function getAccessTokenOptions($method, array $params)
157164
158165 $ signer ->setSignatureContentLength (20000 );
159166 $ tmpDocument = $ signer ->preSign (
160- new SetaPDF_Core_Writer_File (SetaPDF_Core_Writer_TempFile ::createTempPath ()),
167+ new FileWriter (TempFileWriter ::createTempPath ()),
161168 $ module
162169 );
163170 if ($ signAlgorithm === Digest::RSA_PSS_ALGORITHM ) {
@@ -201,12 +208,12 @@ public function getAccessTokenOptions($method, array $params)
201208 $ hashData = $ _SESSION [__FILE__ ]['hashData ' ];
202209
203210 /**
204- * @var SetaPDF_Signer_Signature_Module_Pades $module
211+ * @var Pades $module
205212 */
206213 $ module = $ _SESSION [__FILE__ ]['module ' ];
207214
208215 /**
209- * @var SetaPDF_Signer_TmpDocument $tmpDocument
216+ * @var TmpDocument $tmpDocument
210217 */
211218 $ tmpDocument = $ _SESSION [__FILE__ ]['tmpDocument ' ];
212219
@@ -234,11 +241,11 @@ public function getAccessTokenOptions($method, array $params)
234241 // get the CMS structur from the signature module
235242 $ cms = (string ) $ module ->getCms ();
236243
237- $ reader = new SetaPDF_Core_Reader_File ($ fileToSign );
238- $ tmpWriter = new SetaPDF_Core_Writer_TempFile ();
244+ $ reader = new FileReader ($ fileToSign );
245+ $ tmpWriter = new TempFileWriter ();
239246
240- $ document = SetaPDF_Core_Document ::load ($ reader , $ tmpWriter );
241- $ signer = new SetaPDF_Signer ($ document );
247+ $ document = Document ::load ($ reader , $ tmpWriter );
248+ $ signer = new Signer ($ document );
242249
243250 $ field = $ signer ->getSignatureField ();
244251 $ fieldName = $ field ->getQualifiedName ();
@@ -247,21 +254,21 @@ public function getAccessTokenOptions($method, array $params)
247254 $ signer ->saveSignature ($ tmpDocument , $ cms );
248255 $ document ->finish ();
249256
250- $ writer = new SetaPDF_Core_Writer_String ();
251- $ document = \SetaPDF_Core_Document ::loadByFilename ($ tmpWriter ->getPath (), $ writer );
257+ $ writer = new StringWriter ();
258+ $ document = Document ::loadByFilename ($ tmpWriter ->getPath (), $ writer );
252259
253260 // create a VRI collector instance
254- $ collector = new SetaPDF_Signer_ValidationRelatedInfo_Collector (new SetaPDF_Signer_X509_Collection ($ _SESSION [__FILE__ ]['certificates ' ]));
261+ $ collector = new Collector (new Collection ($ _SESSION [__FILE__ ]['certificates ' ]));
255262 $ vriData = $ collector ->getByFieldName (
256263 $ document ,
257264 $ fieldName ,
258- SetaPDF_Signer_ValidationRelatedInfo_Collector ::SOURCE_OCSP_OR_CRL ,
265+ Collector ::SOURCE_OCSP_OR_CRL ,
259266 null ,
260267 null ,
261268 $ _SESSION [__FILE__ ]['vriData ' ] // pass the previously gathered VRI data
262269 );
263270 // and add it to the document.
264- $ dss = new SetaPDF_Signer_DocumentSecurityStore ($ document );
271+ $ dss = new DocumentSecurityStore ($ document );
265272 $ dss ->addValidationRelatedInfoByFieldName (
266273 $ fieldName ,
267274 $ vriData ->getCrls (),
0 commit comments