Skip to content

Commit 4c037a1

Browse files
committed
Ajustes ao verificar se assinatura ocorreu com sucesso.
1 parent 531c86f commit 4c037a1

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/Sign/JSignService.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ public function sign(JSignParam $params)
2525
$this->validation($params);
2626

2727
$commandSign = $this->commandSign($params);
28-
$output = exec($commandSign);
29-
$isSigned = $output == 'INFO Finished: Signature succesfully created.';
28+
$out = exec($commandSign, $output);
29+
if (is_array($output))
30+
$output = $output[count($output) -1];
31+
32+
$messageSuccess = "INFO Finished: Signature succesfully created.";
33+
$isSigned = ($output == $messageSuccess || $out == $messageSuccess);
3034
$this->throwIf(!$isSigned, "Error to sign PDF. $output");
3135

3236
$fileSigned = $this->fileService->contentFile(
@@ -43,6 +47,7 @@ public function sign(JSignParam $params)
4347
} catch (Throwable $e) {
4448
if ($params->getTempPath())
4549
$this->fileService->deleteTempFiles($params->getTempPath(), $params->getTempName());
50+
4651
throw new Exception($e->getMessage());
4752
}
4853
}
@@ -55,7 +60,7 @@ private function validation(JSignParam $params)
5560
$this->throwIf(empty($params->getPassword()), 'Certificate Password is Empty.');
5661
$this->throwIf(!$this->isPasswordCertificateValid($params->getCertificate(), $params->getPassword()), 'Certificate Password Invalid.');
5762
if ($params->isUseJavaInstalled()) {
58-
$javaVersion = exec("java -version 2>&1");
63+
$javaVersion = exec("java -version 2>&1");
5964
$hasJavaVersion = strpos($javaVersion, 'not found') === false;
6065
$this->throwIf(!$hasJavaVersion, 'Java not installed, set the flag "isUseJavaInstalled" as false or install java.');
6166
}

0 commit comments

Comments
 (0)