|
50 | 50 | use AndrewSvirin\Ebics\Models\UploadOrderResult; |
51 | 51 | use AndrewSvirin\Ebics\Models\UploadTransaction; |
52 | 52 | use AndrewSvirin\Ebics\Models\User; |
| 53 | +use AndrewSvirin\Ebics\Models\X509\ContentX509Generator; |
53 | 54 | use AndrewSvirin\Ebics\Services\CryptService; |
54 | 55 | use AndrewSvirin\Ebics\Services\CurlHttpClient; |
55 | 56 | use AndrewSvirin\Ebics\Services\XmlService; |
@@ -125,9 +126,11 @@ public function __construct(Bank $bank, User $user, Keyring $keyring) |
125 | 126 | * @inheritDoc |
126 | 127 | * @throws EbicsException |
127 | 128 | */ |
128 | | - public function createUserSignatures(string $aVersion = SignatureInterface::A_VERSION6): void |
129 | | - { |
130 | | - $signatureA = $this->createUserSignature(SignatureInterface::TYPE_A); |
| 129 | + public function createUserSignatures( |
| 130 | + string $aVersion = SignatureInterface::A_VERSION6, |
| 131 | + array $aDetails = null |
| 132 | + ): void { |
| 133 | + $signatureA = $this->createUserSignature(SignatureInterface::TYPE_A, $aDetails); |
131 | 134 | $this->keyring->setUserSignatureAVersion($aVersion); |
132 | 135 | $this->keyring->setUserSignatureA($signatureA); |
133 | 136 |
|
@@ -1310,14 +1313,27 @@ private function getUserSignature(string $type): SignatureInterface |
1310 | 1313 | * @return SignatureInterface |
1311 | 1314 | * @throws EbicsException |
1312 | 1315 | */ |
1313 | | - private function createUserSignature(string $type): SignatureInterface |
| 1316 | + private function createUserSignature(string $type, array $details = null): SignatureInterface |
1314 | 1317 | { |
1315 | 1318 | switch ($type) { |
1316 | 1319 | case SignatureInterface::TYPE_A: |
| 1320 | + if (null === $details) { |
| 1321 | + $keys = $this->cryptService->generateKeys($this->keyring->getPassword()); |
| 1322 | + $certificateGenerator = $this->keyring->getCertificateGenerator(); |
| 1323 | + } else { |
| 1324 | + $keys = $this->cryptService->changePrivateKeyPassword( |
| 1325 | + $details['privatekey'], |
| 1326 | + $details['password'], |
| 1327 | + $this->keyring->getPassword() |
| 1328 | + ); |
| 1329 | + $certificateGenerator = new ContentX509Generator(); |
| 1330 | + $certificateGenerator->setAContent($details['certificate']); |
| 1331 | + } |
| 1332 | + |
1317 | 1333 | $signature = $this->signatureFactory->createSignatureAFromKeys( |
1318 | | - $this->cryptService->generateKeys($this->keyring->getPassword()), |
| 1334 | + $keys, |
1319 | 1335 | $this->keyring->getPassword(), |
1320 | | - $this->keyring->getCertificateGenerator() |
| 1336 | + $certificateGenerator |
1321 | 1337 | ); |
1322 | 1338 | break; |
1323 | 1339 | case SignatureInterface::TYPE_E: |
|
0 commit comments