Skip to content

Commit

Permalink
Moved fortify session writing to be compatible with other data backends
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianKresse committed Apr 23, 2024
1 parent 3404e21 commit 2390785
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,25 @@
$tempPath = \SetaPDF_Core_Writer_TempFile::createTempPath();

// prepare the PDF
$_SESSION['tmpDocument'] = $signer->preSign(
$tmpDocument = $signer->preSign(
new \SetaPDF_Core_Writer_File($tempPath),
$module
);

$_SESSION['module'] = $module;


// prepare the response
$response = [
'dataToSign' => \SetaPDF_Core_Type_HexString::str2hex(
$module->getDataToSign($_SESSION['tmpDocument']->getHashFile())
$module->getDataToSign($tmpDocument->getHashFile())
),
'extraCerts' => array_map(function (\SetaPDF_Signer_X509_Certificate $cert) {
return $cert->get(\SetaPDF_Signer_X509_Format::PEM);
}, $extraCerts->getAll()),
'tsUrl' => isset($_SESSION['tsUrl']) ? $_SESSION['tsUrl'] : false
];

$_SESSION['tmpDocument'] = $tmpDocument;
$_SESSION['module'] = $module;

// send it
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,22 @@
$tempPath = \SetaPDF_Core_Writer_TempFile::createTempPath();

// prepare the PDF
$_SESSION['tmpDocument'] = $signer->preSign(
$tmpDocument = $signer->preSign(
new \SetaPDF_Core_Writer_File($tempPath),
$module
);

$_SESSION['module'] = $module;

// prepare the response
$response = [
'dataToSign' => \SetaPDF_Core_Type_HexString::str2hex(
$module->getDataToSign($_SESSION['tmpDocument']->getHashFile())
$module->getDataToSign($tmpDocument->getHashFile())
)
];

$_SESSION['module'] = $module;
$_SESSION['tmpDocument'] = $tmpDocument;

// send it
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@
];
}

$_SESSION['tmpDocuments'] = $tmpDocuments;


// prepare the response
$response = [
'dataToSign' => array_map(function ($tmpDocument) {
Expand All @@ -153,6 +150,8 @@
'tsUrl' => isset($_SESSION['tsUrl']) ? $_SESSION['tsUrl'] : false
];

$_SESSION['tmpDocuments'] = $tmpDocuments;

// send it
header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
Expand Down

0 comments on commit 2390785

Please sign in to comment.