Skip to content

Commit 0b9fbd5

Browse files
committed
upd euspe
1 parent 74f18cf commit 0b9fbd5

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

src/Client.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ private function handleResult(string $command, $iResult, int $iErrorCode = null,
1919
{
2020
if (!empty($iErrorCode) && !in_array($iErrorCode, $aAcceptableErrorCodes)) {
2121
euspe_geterrdescr($iErrorCode, $sErrorDescription);
22+
$utfEncoding = 'utf-8';
2223
throw new Exception(
2324
sprintf(
2425
'Result: %s Code: %s Command: %s Error: %s. Check error in EUSignConsts.php by code.',
2526
dechex($iResult),
2627
dechex($iErrorCode),
2728
$command,
28-
($encoding = mb_detect_encoding($sErrorDescription)) && $encoding !== 'UTF-8' ?
29-
mb_convert_encoding($sErrorDescription, $encoding, 'utf-8') :
29+
($encoding = mb_detect_encoding($sErrorDescription)) && strtolower($encoding) !== $utfEncoding ?
30+
mb_convert_encoding($sErrorDescription, $encoding, $utfEncoding) :
3031
$sErrorDescription
3132
)
3233
);
@@ -242,29 +243,4 @@ function envelopData(string $data, array $certs): string
242243
// TODO: Implement envelopData() method.
243244
return '';
244245
}
245-
246-
public static function getInstanceClient(string $secretToken, KeyRingStorage $keyRingStorage, User $user, bool $hasCerts): ?self
247-
{
248-
$client = new self();
249-
$client->open();
250-
$keyRing = $keyRingStorage->prepare($user);
251-
if (!$keyRingStorage->exists($keyRing)) {
252-
$keyRing->setPassword($user->getPassword());
253-
$keyRing->setType($user->getKeyType());
254-
if ($keyRing->typeIsDAT()) {
255-
$keyRing->setPrivateKeys([$user->getKeyData()]);
256-
} else {
257-
$keyRing->setPrivateKeys($client->retrieveJKSPrivateKeys($user->getKeyData()));
258-
}
259-
$keyRingStorage->store($keyRing, $secretToken);
260-
}
261-
$keyRingStorage->load($keyRing, $secretToken);
262-
if (!$hasCerts) {
263-
foreach ($keyRing->getPrivateKeys() as $privateKey) {
264-
$client->readPrivateKey($privateKey, $keyRing->getPassword());
265-
$client->resetPrivateKey();
266-
}
267-
}
268-
return $client;
269-
}
270246
}

0 commit comments

Comments
 (0)