1414use EbicsApi \Ebics \Factories \SignatureFactory ;
1515use EbicsApi \Ebics \Handlers \Traits \H00XTrait ;
1616use EbicsApi \Ebics \Models \CustomerH3K ;
17+ use EbicsApi \Ebics \Models \CustomerHCS ;
1718use EbicsApi \Ebics \Models \CustomerHIA ;
1819use EbicsApi \Ebics \Models \CustomerINI ;
1920use EbicsApi \Ebics \Models \Keyring ;
2021use EbicsApi \Ebics \Models \User ;
22+ use EbicsApi \Ebics \Models \XmlData ;
2123use EbicsApi \Ebics \Models \XmlDocument ;
2224use EbicsApi \Ebics \Services \CryptService ;
2325
@@ -56,13 +58,16 @@ public function __construct(
5658 $ this ->bigIntegerFactory = $ bigIntegerFactory ;
5759 }
5860
59- abstract protected function createSignaturePubKeyOrderData (CustomerINI $ xml ): DOMElement ;
61+ abstract protected function createSignaturePubKeyOrderData (XmlData $ xml ): DOMElement ;
6062
61- abstract protected function handleINISignaturePubKey (
63+ abstract protected function createHCSRequestOrderData (XmlData $ xml ): DOMElement ;
64+
65+ abstract protected function handleSignaturePubKey (
6266 DOMElement $ xmlSignaturePubKeyInfo ,
63- CustomerINI $ xml ,
67+ XmlData $ xml ,
6468 SignatureInterface $ certificateA ,
65- DateTimeInterface $ dateTime
69+ DateTimeInterface $ dateTime ,
70+ string $ ns = ''
6671 ): void ;
6772
6873 /**
@@ -89,7 +94,7 @@ public function handleINI(CustomerINI $xml, SignatureInterface $certificateA, Da
8994 $ this ->handleX509Data ($ xmlSignaturePubKeyInfo , $ xml , $ certificateA );
9095 }
9196
92- $ this ->handleINISignaturePubKey ($ xmlSignaturePubKeyInfo , $ xml , $ certificateA , $ dateTime );
97+ $ this ->handleSignaturePubKey ($ xmlSignaturePubKeyInfo , $ xml , $ certificateA , $ dateTime );
9398
9499 // Add SignatureVersion to SignaturePubKeyInfo.
95100 $ xmlSignatureVersion = $ xml ->createElement ('SignatureVersion ' );
@@ -111,18 +116,20 @@ protected function createHIARequestOrderData(CustomerHIA $xml): DOMElement
111116 );
112117 }
113118
114- abstract protected function handleHIAAuthenticationPubKey (
119+ abstract protected function handleAuthenticationPubKey (
115120 DOMElement $ xmlAuthenticationPubKeyInfo ,
116- CustomerHIA $ xml ,
121+ XmlData $ xml ,
117122 SignatureInterface $ certificateX ,
118- DateTimeInterface $ dateTime
123+ DateTimeInterface $ dateTime ,
124+ string $ ns = ''
119125 ): void ;
120126
121- abstract protected function handleHIAEncryptionPubKey (
127+ abstract protected function handleEncryptionPubKey (
122128 DOMElement $ xmlEncryptionPubKeyInfo ,
123- CustomerHIA $ xml ,
129+ XmlData $ xml ,
124130 SignatureInterface $ certificateE ,
125- DateTimeInterface $ dateTime
131+ DateTimeInterface $ dateTime ,
132+ string $ ns = ''
126133 ): void ;
127134
128135 /**
@@ -154,7 +161,7 @@ public function handleHIA(
154161 $ this ->handleX509Data ($ xmlAuthenticationPubKeyInfo , $ xml , $ certificateX );
155162 }
156163
157- $ this ->handleHIAAuthenticationPubKey ($ xmlAuthenticationPubKeyInfo , $ xml , $ certificateX , $ dateTime );
164+ $ this ->handleAuthenticationPubKey ($ xmlAuthenticationPubKeyInfo , $ xml , $ certificateX , $ dateTime );
158165
159166 // Add AuthenticationVersion to AuthenticationPubKeyInfo.
160167 $ xmlAuthenticationVersion = $ xml ->createElement ('AuthenticationVersion ' );
@@ -169,7 +176,7 @@ public function handleHIA(
169176 $ this ->handleX509Data ($ xmlEncryptionPubKeyInfo , $ xml , $ certificateE );
170177 }
171178
172- $ this ->handleHIAEncryptionPubKey ($ xmlEncryptionPubKeyInfo , $ xml , $ certificateE , $ dateTime );
179+ $ this ->handleEncryptionPubKey ($ xmlEncryptionPubKeyInfo , $ xml , $ certificateE , $ dateTime );
173180
174181 // Add EncryptionVersion to EncryptionPubKeyInfo.
175182 $ xmlEncryptionVersion = $ xml ->createElement ('EncryptionVersion ' );
@@ -183,6 +190,77 @@ public function handleHIA(
183190 $ this ->handleUserId ($ xmlHIARequestOrderData , $ xml );
184191 }
185192
193+ /**
194+ * Adds OrderData DOM elements to XML DOM for HCS request.
195+ *
196+ * @throws EbicsException
197+ */
198+ public function handleHCS (
199+ CustomerHCS $ xml ,
200+ SignatureInterface $ certificateA ,
201+ SignatureInterface $ certificateE ,
202+ SignatureInterface $ certificateX ,
203+ DateTimeInterface $ dateTime
204+ ): void {
205+ // Add HCSRequestOrderData to root.
206+ $ xmlHCSRequestOrderData = $ this ->createHCSRequestOrderData ($ xml );
207+ $ xml ->appendChild ($ xmlHCSRequestOrderData );
208+
209+
210+ // Add AuthenticationPubKeyInfo to HIARequestOrderData.
211+ $ xmlAuthenticationPubKeyInfo = $ xml ->createElement ('AuthenticationPubKeyInfo ' );
212+ $ xmlHCSRequestOrderData ->appendChild ($ xmlAuthenticationPubKeyInfo );
213+
214+ if ($ this ->keyring ->isCertified ()) {
215+ $ this ->handleX509Data ($ xmlAuthenticationPubKeyInfo , $ xml , $ certificateX );
216+ }
217+
218+ $ this ->handleAuthenticationPubKey ($ xmlAuthenticationPubKeyInfo , $ xml , $ certificateX , $ dateTime );
219+
220+ // Add AuthenticationVersion to AuthenticationPubKeyInfo.
221+ $ xmlAuthenticationVersion = $ xml ->createElement ('AuthenticationVersion ' );
222+ $ xmlAuthenticationVersion ->nodeValue = $ this ->keyring ->getUserSignatureXVersion ();
223+ $ xmlAuthenticationPubKeyInfo ->appendChild ($ xmlAuthenticationVersion );
224+
225+
226+ // Add EncryptionPubKeyInfo to HCSRequestOrderData.
227+ $ xmlEncryptionPubKeyInfo = $ xml ->createElement ('EncryptionPubKeyInfo ' );
228+ $ xmlHCSRequestOrderData ->appendChild ($ xmlEncryptionPubKeyInfo );
229+
230+ if ($ this ->keyring ->isCertified ()) {
231+ $ this ->handleX509Data ($ xmlEncryptionPubKeyInfo , $ xml , $ certificateE );
232+ }
233+
234+ $ this ->handleEncryptionPubKey ($ xmlEncryptionPubKeyInfo , $ xml , $ certificateE , $ dateTime );
235+
236+ // Add EncryptionVersion to EncryptionPubKeyInfo.
237+ $ xmlEncryptionVersion = $ xml ->createElement ('EncryptionVersion ' );
238+ $ xmlEncryptionVersion ->nodeValue = $ this ->keyring ->getUserSignatureEVersion ();
239+ $ xmlEncryptionPubKeyInfo ->appendChild ($ xmlEncryptionVersion );
240+
241+
242+ // Add SignaturePubKeyInfo to SignaturePubKeyOrderData.
243+ $ xmlSignaturePubKeyInfo = $ xml ->createElement ('esig:SignaturePubKeyInfo ' );
244+ $ xmlHCSRequestOrderData ->appendChild ($ xmlSignaturePubKeyInfo );
245+
246+ if ($ this ->keyring ->isCertified ()) {
247+ $ this ->handleX509Data ($ xmlSignaturePubKeyInfo , $ xml , $ certificateA );
248+ }
249+
250+ $ this ->handleSignaturePubKey ($ xmlSignaturePubKeyInfo , $ xml , $ certificateA , $ dateTime , 'esig ' );
251+
252+ // Add SignatureVersion to SignaturePubKeyInfo.
253+ $ xmlSignatureVersion = $ xml ->createElement ('esig:SignatureVersion ' );
254+ $ xmlSignatureVersion ->nodeValue = $ this ->keyring ->getUserSignatureAVersion ();
255+ $ xmlSignaturePubKeyInfo ->appendChild ($ xmlSignatureVersion );
256+
257+ // Add PartnerID to HIARequestOrderData.
258+ $ this ->handlePartnerId ($ xmlHCSRequestOrderData , $ xml );
259+
260+ // Add UserID to HIARequestOrderData.
261+ $ this ->handleUserId ($ xmlHCSRequestOrderData , $ xml );
262+ }
263+
186264 /**
187265 * Adds OrderData DOM elements to XML DOM for H3K request.
188266 *
0 commit comments