@@ -82,7 +82,7 @@ |
||
82 | 82 | |
83 | 83 | $httpcode = $this->dispose_curl($curl, $response, $data->urlMethod); |
84 | 84 | } |
85 | - catch(\Exception $e) { |
|
85 | + catch (\Exception $e) { |
|
86 | 86 | throw SoapException::unableToLoadCurl($e->getMessage()); |
87 | 87 | } |
88 | 88 |
@@ -81,16 +81,17 @@ |
||
81 | 81 | $response = curl_exec($curl); |
82 | 82 | |
83 | 83 | $httpcode = $this->dispose_curl($curl, $response, $data->urlMethod); |
84 | - } |
|
85 | - catch(\Exception $e) { |
|
84 | + } catch(\Exception $e) { |
|
86 | 85 | throw SoapException::unableToLoadCurl($e->getMessage()); |
87 | 86 | } |
88 | 87 | |
89 | - if ($this->soaperror != '') |
|
90 | - throw SoapException::soapFault($this->soaperror . " [$url]"); |
|
88 | + if ($this->soaperror != '') { |
|
89 | + throw SoapException::soapFault($this->soaperror . " [$url]"); |
|
90 | + } |
|
91 | 91 | |
92 | - if ($httpcode != 200) |
|
93 | - throw SoapException::soapFault(" [$url]" . $this->responseHead); |
|
92 | + if ($httpcode != 200) { |
|
93 | + throw SoapException::soapFault(" [$url]" . $this->responseHead); |
|
94 | + } |
|
94 | 95 | |
95 | 96 | return $this->responseBody; |
96 | 97 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | class Signer |
34 | 34 | { |
35 | - const CANONICAL = array(true,false,null,null); |
|
35 | + const CANONICAL = array(true, false, null, null); |
|
36 | 36 | private static $canonical = self::CANONICAL; |
37 | 37 | |
38 | 38 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
144 | 144 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
145 | 145 | } |
146 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
146 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
147 | 147 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
148 | 148 | $idSigned = trim($node->getAttribute($mark)); |
149 | 149 | $signatureNode = $dom->createElementNS($nsDSIG, 'Signature'); |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | $canonical |
72 | 72 | ); |
73 | 73 | |
74 | - if (!Signer::isSigned($signed->saveXML(), $tagName)) |
|
75 | - throw SignerException::signatureComparisonFailed(); |
|
74 | + if (!Signer::isSigned($signed->saveXML(), $tagName)) { |
|
75 | + throw SignerException::signatureComparisonFailed(); |
|
76 | + } |
|
76 | 77 | } |
77 | 78 | |
78 | 79 | return $signed; |
@@ -100,8 +101,9 @@ discard block |
||
100 | 101 | int $algorithm = OPENSSL_ALGO_SHA1, |
101 | 102 | $canonical = self::CANONICAL |
102 | 103 | ): DOMDocument { |
103 | - if (!empty($canonical)) |
|
104 | - self::$canonical = $canonical; |
|
104 | + if (!empty($canonical)) { |
|
105 | + self::$canonical = $canonical; |
|
106 | + } |
|
105 | 107 | |
106 | 108 | return self::createSignature( |
107 | 109 | $certificate, |
@@ -201,8 +203,9 @@ discard block |
||
201 | 203 | * @return string |
202 | 204 | */ |
203 | 205 | public static function removeSignature(string $content): string { |
204 | - if (!self::existsSignature($content)) |
|
205 | - return $content; |
|
206 | + if (!self::existsSignature($content)) { |
|
207 | + return $content; |
|
208 | + } |
|
206 | 209 | |
207 | 210 | $dom = new \DOMDocument('1.0', 'utf-8'); |
208 | 211 | $dom->formatOutput = false; |
@@ -228,11 +231,13 @@ discard block |
||
228 | 231 | * @throws SignerException Not is a XML, Digest or Signature dont match |
229 | 232 | */ |
230 | 233 | public static function isSigned(string $content, string $tagname = '', $canonical = self::CANONICAL): bool { |
231 | - if (!self::existsSignature($content)) |
|
232 | - return false; |
|
234 | + if (!self::existsSignature($content)) { |
|
235 | + return false; |
|
236 | + } |
|
233 | 237 | |
234 | - if (!self::digestCheck($content, $tagname, $canonical)) |
|
235 | - return false; |
|
238 | + if (!self::digestCheck($content, $tagname, $canonical)) { |
|
239 | + return false; |
|
240 | + } |
|
236 | 241 | |
237 | 242 | return self::signatureCheck($content, $canonical); |
238 | 243 | } |
@@ -243,8 +248,9 @@ discard block |
||
243 | 248 | * @return boolean |
244 | 249 | */ |
245 | 250 | public static function existsSignature(string $content): bool { |
246 | - if (!Validator::isXML($content)) |
|
247 | - throw SignerException::isNotXml(); |
|
251 | + if (!Validator::isXML($content)) { |
|
252 | + throw SignerException::isNotXml(); |
|
253 | + } |
|
248 | 254 | |
249 | 255 | $dom = new \DOMDocument('1.0', 'utf-8'); |
250 | 256 | $dom->formatOutput = false; |
@@ -286,8 +292,9 @@ discard block |
||
286 | 292 | str_replace(array("\r", "\n"), '', $signatureValue) |
287 | 293 | ); |
288 | 294 | |
289 | - if (!$publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) |
|
290 | - throw SignerException::signatureComparisonFailed(); |
|
295 | + if (!$publicKey->verify($signInfoNode, $decodedSignature, $algorithm)) { |
|
296 | + throw SignerException::signatureComparisonFailed(); |
|
297 | + } |
|
291 | 298 | |
292 | 299 | return true; |
293 | 300 | } |
@@ -324,17 +331,19 @@ discard block |
||
324 | 331 | } |
325 | 332 | } |
326 | 333 | $node = $dom->getElementsByTagName($tagname)->item(0); |
327 | - if (empty($node)) |
|
328 | - throw SignerException::tagNotFound($tagname); |
|
329 | - } |
|
330 | - else { |
|
334 | + if (empty($node)) { |
|
335 | + throw SignerException::tagNotFound($tagname); |
|
336 | + } |
|
337 | + } else { |
|
331 | 338 | $node = $dom->getElementsByTagName($tagname)->item(0); |
332 | - if (empty($node)) |
|
333 | - throw SignerException::tagNotFound($tagname); |
|
339 | + if (empty($node)) { |
|
340 | + throw SignerException::tagNotFound($tagname); |
|
341 | + } |
|
334 | 342 | |
335 | 343 | $signature = $node->nextSibling; |
336 | - if ($signature->nodeName !== 'Signature') |
|
337 | - throw SignerException::tagNotFound('Signature'); |
|
344 | + if ($signature->nodeName !== 'Signature') { |
|
345 | + throw SignerException::tagNotFound('Signature'); |
|
346 | + } |
|
338 | 347 | |
339 | 348 | $sigURI = $signature->getElementsByTagName('Reference')->item(0)->getAttribute('URI'); |
340 | 349 | } |
@@ -353,8 +362,9 @@ discard block |
||
353 | 362 | $calculatedDigest = self::makeDigest($node, $algorithm, $canonical); |
354 | 363 | $informedDigest = $signature->getElementsByTagName('DigestValue')->item(0)->nodeValue; |
355 | 364 | |
356 | - if ($calculatedDigest != $informedDigest) |
|
357 | - throw SignerException::digestComparisonFailed(); |
|
365 | + if ($calculatedDigest != $informedDigest) { |
|
366 | + throw SignerException::digestComparisonFailed(); |
|
367 | + } |
|
358 | 368 | |
359 | 369 | return true; |
360 | 370 | } |