Skip to content

Commit fb4e45d

Browse files
committed
fix: use stdClass instead of arrays in loadSignersFromCertData
Convert array access to stdClass properties in loadSignersFromCertData to maintain consistency with loadLibreSignSigners expectations. Signed-off-by: Vitor Mattos <[email protected]>
1 parent eca5ae0 commit fb4e45d

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

lib/Service/File/SignersLoader.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,33 @@ public function loadLibreSignSigners(
196196

197197
public function loadSignersFromCertData(stdClass $fileData, array $certData, FileResponseOptions $options): void {
198198
foreach ($certData as $index => $signer) {
199-
$fileData->signers[$index]['status'] = 2;
200-
$fileData->signers[$index]['statusText'] = $this->signRequestMapper->getTextOfSignerStatus(2);
199+
if (!isset($fileData->signers[$index])) {
200+
$fileData->signers[$index] = new stdClass();
201+
}
202+
$fileData->signers[$index]->status = 2;
203+
$fileData->signers[$index]->statusText = $this->signRequestMapper->getTextOfSignerStatus(2);
201204

202205
if (isset($signer['timestamp'])) {
203-
$fileData->signers[$index]['timestamp'] = $signer['timestamp'];
206+
$fileData->signers[$index]->timestamp = $signer['timestamp'];
204207
if (isset($signer['timestamp']['genTime']) && $signer['timestamp']['genTime'] instanceof DateTimeInterface) {
205-
$fileData->signers[$index]['timestamp']['genTime'] = $signer['timestamp']['genTime']->format(DateTimeInterface::ATOM);
208+
$fileData->signers[$index]->timestamp['genTime'] = $signer['timestamp']['genTime']->format(DateTimeInterface::ATOM);
206209
}
207210
}
208211
if (isset($signer['signingTime']) && $signer['signingTime'] instanceof DateTimeInterface) {
209-
$fileData->signers[$index]['signingTime'] = $signer['signingTime'];
210-
$fileData->signers[$index]['signed'] = $signer['signingTime']->format(DateTimeInterface::ATOM);
212+
$fileData->signers[$index]->signingTime = $signer['signingTime'];
213+
$fileData->signers[$index]->signed = $signer['signingTime']->format(DateTimeInterface::ATOM);
211214
}
212215
if (isset($signer['docmdp'])) {
213-
$fileData->signers[$index]['docmdp'] = $signer['docmdp'];
216+
$fileData->signers[$index]->docmdp = $signer['docmdp'];
214217
}
215218
if (isset($signer['modifications'])) {
216-
$fileData->signers[$index]['modifications'] = $signer['modifications'];
219+
$fileData->signers[$index]->modifications = $signer['modifications'];
217220
}
218221
if (isset($signer['modification_validation'])) {
219-
$fileData->signers[$index]['modification_validation'] = $signer['modification_validation'];
222+
$fileData->signers[$index]->modification_validation = $signer['modification_validation'];
220223
}
221224
if (isset($signer['chain'])) {
225+
$fileData->signers[$index]->chain = [];
222226
foreach ($signer['chain'] as $chainIndex => $chainItem) {
223227
$chainArr = $chainItem;
224228
if (isset($chainItem['validFrom_time_t']) && is_numeric($chainItem['validFrom_time_t'])) {
@@ -228,21 +232,25 @@ public function loadSignersFromCertData(stdClass $fileData, array $certData, Fil
228232
$chainArr['valid_to'] = (new DateTime('@' . $chainItem['validTo_time_t'], new \DateTimeZone('UTC')))->format(DateTimeInterface::ATOM);
229233
}
230234
$chainArr['displayName'] = $chainArr['name'] ?? ($chainArr['subject']['CN'] ?? '');
231-
$fileData->signers[$index]['chain'][$chainIndex] = $chainArr;
235+
$fileData->signers[$index]->chain[$chainIndex] = $chainArr;
232236
if ($chainIndex === 0) {
233-
$fileData->signers[$index] = array_merge($chainArr, $fileData->signers[$index] ?? []);
234-
$fileData->signers[$index]['uid'] = $this->identifyMethodService->resolveUid($chainArr, $options->getHost());
237+
foreach ($chainArr as $key => $value) {
238+
if (!isset($fileData->signers[$index]->$key)) {
239+
$fileData->signers[$index]->$key = $value;
240+
}
241+
}
242+
$fileData->signers[$index]->uid = $this->identifyMethodService->resolveUid($chainArr, $options->getHost());
235243
}
236244
}
237245
}
238246
if (isset($signer['uid'])) {
239-
$fileData->signers[$index]['uid'] = $signer['uid'];
247+
$fileData->signers[$index]->uid = $signer['uid'];
240248
}
241249
if (isset($signer['signDate'])) {
242-
$fileData->signers[$index]['signDate'] = $signer['signDate'];
250+
$fileData->signers[$index]->signDate = $signer['signDate'];
243251
}
244252
if (isset($signer['type'])) {
245-
$fileData->signers[$index]['type'] = $signer['type'];
253+
$fileData->signers[$index]->type = $signer['type'];
246254
}
247255
}
248256
}

0 commit comments

Comments
 (0)