options = $options; $this->credentials = $credentials; $this->tanMode = $tanMode instanceof NoPsd2TanMode ? null : $tanMode; $this->tanMedium = $tanMedium; $this->kundensystemId = $kundensystemId; $this->hktanRef = $hktanRef; } /** * @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023 */ public function serialize(): string { return serialize($this->__serialize()); } public function __serialize(): array { return [ parent::__serialize(), $this->hktanRef, $this->kundensystemId, $this->messageNumber, $this->dialogId, ]; } /** * @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023 * * @param string $serialized * @return void */ public function unserialize($serialized) { self::__unserialize(unserialize($serialized)); } public function __unserialize(array $serialized): void { list( $parentSerialized, $this->hktanRef, $this->kundensystemId, $this->messageNumber, $this->dialogId, ) = $serialized; is_array($parentSerialized) ? parent::__unserialize($parentSerialized) : parent::unserialize($parentSerialized); } protected function createRequest(BPD $bpd, ?UPD $upd) { throw new \AssertionError('DialogInitialization::createRequest should not be used.'); } /** * @param BPD|null $bpd The BPD. Note that we support null here because a dialog initialization is how the BPD can * be obtained in the first place. * @param UPD|null $upd The UPD. * @return array|\Fhp\Segment\BaseSegment|\Fhp\Segment\BaseSegment[] */ public function getNextRequest(?BPD $bpd, ?UPD $upd) { $request = [ HKIDNv2::create($this->options->bankCode, $this->credentials, $this->kundensystemId ?? '0'), HKVVBv3::create($this->options, $bpd, $upd), ]; if ($this->tanMode !== null) { $request[] = HKTANFactory::createProzessvariante2Step1( $this->tanMode, $this->tanMedium, $this->hktanRef ?? 'HKIDN'); } if ($this->kundensystemId === null) { // NOTE: HKSYN must be *after* HKTAN. $request[] = HKSYNv3::createEmpty(); // See section C.8.1.1 } return $request; } public function processResponse(Message $response) { parent::processResponse($response); $this->dialogId = $response->header->dialogId; if ($this->kundensystemId === null) { /** @var HISYNv4 $hisyn */ $hisyn = $response->requireSegment(HISYNv4::class); if ($hisyn->kundensystemId === null) { throw new UnexpectedResponseException('No Kundensystem-ID received'); } $this->kundensystemId = $hisyn->kundensystemId; } if (UPD::containedInResponse($response)) { $this->upd = UPD::extractFromResponse($response); } } public function isStronglyAuthenticated(): bool { return $this->hktanRef === 'HKIDN'; } public function getKundensystemId(): ?string { return $this->kundensystemId; } public function getMessageNumber(): ?int { return $this->messageNumber; } public function setMessageNumber(?int $messageNumber): void { $this->messageNumber = $messageNumber; } public function getDialogId(): ?string { return $this->dialogId; } /** * To be called when a TAN is required for login, but we need to intermittently store the Dialog-ID. */ public function setDialogId(?string $dialogId): void { $this->dialogId = $dialogId; } public function getUpd(): ?UPD { return $this->upd; } }