dolibarr.bankimport/vendor/nemiah/php-fints/lib/Fhp/Model/TanRequestChallengeImage.php
data 8b64fd24d3 feat: php-fints 4.0 Update + HKEKA/HKKAA Segmente (WIP)
- php-fints Bibliothek von 3.7.0 auf 4.0.0 aktualisiert
- Parser-Fix: Ignoriert zusätzliche Bank-Felder statt Exception
- HKEKA Segmente implementiert (HIEKASv5, HKEKAv5, HIEKAv5)
- HKKAA Segmente implementiert (HIKAASv1, HKKAAv1)
- GetStatementFromArchive und GetElectronicStatement Actions

HINWEIS: HKKAA/HKEKA funktionieren noch nicht mit VR Bank
(Fehler "unerwarteter Aufbau wrt DE 2" - Kontoverbindungsformat)
Normale Funktionalität (Transaktionsimport) ist nicht betroffen.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-05 15:47:27 +01:00

64 lines
2.1 KiB
PHP

<?php
namespace Fhp\Model;
use Fhp\Syntax\Bin;
class TanRequestChallengeImage
{
private $mimeType;
private $data;
public function __construct(Bin $bin)
{
$data = $bin->getData();
// Documentation: https://www.hbci-zka.de/dokumente/spezifikation_deutsch/hhd/Belegungsrichtlinien%20TANve1.5%20FV%20vom%202018-04-16.pdf
// II.3
// Matrix-Format:
// 2 bytes = length of mime type
// mime type as string
// 2 bytes = length of data
$dataLength = strlen($data);
if ($dataLength < 2) {
throw new \InvalidArgumentException(
"Invalid TAN challenge. Expected image MIME type but only found $dataLength bytes. ");
}
$mimeTypeLengthString = substr($data, 0, 2);
$mimeTypeLength = ord($mimeTypeLengthString[0]) * 256 + ord($mimeTypeLengthString[1]);
if ($dataLength < 2 + $mimeTypeLength + 2) {
throw new \InvalidArgumentException(
"Invalid TAN challenge. Expected image MIME type of length $mimeTypeLength but only found $dataLength bytes. " .
'Maybe the challenge is not an image but rather a URL or a flicker code.');
}
$this->mimeType = substr($data, 2, $mimeTypeLength);
$data = substr($data, 2 + $mimeTypeLength);
$dataLengthString = substr($data, 0, 2);
$expectedDataLength = ord($dataLengthString[0]) * 256 + ord($dataLengthString[1]);
$actualDataLength = strlen($data) - 2;
if ($expectedDataLength != $actualDataLength) {
// This exception is thrown, if there is an encoding problem
// f.e.: the serialized action was saved as a string, but not base64 encoded
throw new \InvalidArgumentException(
"Unexpected data length, expected $expectedDataLength but found $actualDataLength bytes.");
}
$this->data = substr($data, 2, $expectedDataLength);
}
public function getMimeType(): string
{
return $this->mimeType;
}
public function getData(): string
{
return $this->data;
}
}