@@ -35,12 +35,12 @@ import eu.europa.ec.eudi.wallet.document.sample.SampleDocumentManager
35
35
import eu.europa.ec.eudi.wallet.internal.getCertificate
36
36
import eu.europa.ec.eudi.wallet.internal.mainExecutor
37
37
import eu.europa.ec.eudi.wallet.issue.openid4vci.*
38
+ import eu.europa.ec.eudi.wallet.keystore.KeyGenerator
39
+ import eu.europa.ec.eudi.wallet.keystore.KeyGeneratorImpl
38
40
import eu.europa.ec.eudi.wallet.transfer.openid4vp.OpenId4VpCBORResponse
39
- import eu.europa.ec.eudi.wallet.transfer.openid4vp.responseGenerator.OpenId4VpResponseGeneratorDelegator
40
41
import eu.europa.ec.eudi.wallet.transfer.openid4vp.OpenId4vpManager
42
+ import eu.europa.ec.eudi.wallet.transfer.openid4vp.responseGenerator.OpenId4VpResponseGeneratorDelegator
41
43
import eu.europa.ec.eudi.wallet.util.DefaultNfcEngagementService
42
- import eu.europa.ec.eudi.wallet.keystore.KeyGenerator
43
- import eu.europa.ec.eudi.wallet.keystore.KeyGeneratorImpl
44
44
import java.security.cert.X509Certificate
45
45
import java.util.concurrent.Executor
46
46
@@ -229,7 +229,10 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
229
229
* @return [StoreDocumentResult]
230
230
* @throws IllegalStateException if [EudiWallet] is not firstly initialized via the [init] method
231
231
*/
232
- fun storeIssuedDocument (unsignedDocument : UnsignedDocument , data : ByteArray ): StoreDocumentResult =
232
+ fun storeIssuedDocument (
233
+ unsignedDocument : UnsignedDocument ,
234
+ data : ByteArray
235
+ ): StoreDocumentResult =
233
236
documentManager.storeIssuedDocument(unsignedDocument, data)
234
237
235
238
private var openId4VciManager: OpenId4VciManager ? = null
@@ -285,7 +288,15 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
285
288
config(config)
286
289
logger = this @EudiWallet.logger
287
290
ktorHttpClientFactory = _config .ktorHttpClientFactory
288
- }.also { it.issueDocumentByDocType(docType, txCode, executor, authorizationHandler, onEvent) }
291
+ }.also {
292
+ it.issueDocumentByDocType(
293
+ docType,
294
+ txCode,
295
+ executor,
296
+ authorizationHandler,
297
+ onEvent
298
+ )
299
+ }
289
300
} ? : run {
290
301
(executor ? : context.mainExecutor()).execute {
291
302
onEvent(IssueEvent .failure(IllegalStateException (" OpenId4Vci config is not set in configuration" )))
@@ -321,7 +332,15 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
321
332
config(config)
322
333
logger = this @EudiWallet.logger
323
334
ktorHttpClientFactory = _config .ktorHttpClientFactory
324
- }.also { it.issueDocumentByOffer(offer, txCode, executor, authorizationHandler, onEvent) }
335
+ }.also {
336
+ it.issueDocumentByOffer(
337
+ offer,
338
+ txCode,
339
+ executor,
340
+ authorizationHandler,
341
+ onEvent
342
+ )
343
+ }
325
344
} ? : run {
326
345
(executor ? : context.mainExecutor()).execute {
327
346
onEvent(IssueEvent .failure(IllegalStateException (" OpenId4Vci config is not set in configuration" )))
@@ -356,7 +375,15 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
356
375
config(config)
357
376
logger = this @EudiWallet.logger
358
377
ktorHttpClientFactory = _config .ktorHttpClientFactory
359
- }.also { it.issueDocumentByOfferUri(offerUri, txCode, executor, authorizationHandler, onEvent) }
378
+ }.also {
379
+ it.issueDocumentByOfferUri(
380
+ offerUri,
381
+ txCode,
382
+ executor,
383
+ authorizationHandler,
384
+ onEvent
385
+ )
386
+ }
360
387
} ? : run {
361
388
(executor ? : context.mainExecutor()).execute {
362
389
onEvent(IssueEvent .failure(IllegalStateException (" OpenId4Vci config is not set in configuration" )))
@@ -388,7 +415,12 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
388
415
ktorHttpClientFactory = _config .ktorHttpClientFactory
389
416
}.also {
390
417
when (val document = documentManager.getDocumentById(documentId)) {
391
- is DeferredDocument -> it.issueDeferredDocument(document, executor, onResult)
418
+ is DeferredDocument -> it.issueDeferredDocument(
419
+ document,
420
+ executor,
421
+ onResult
422
+ )
423
+
392
424
else -> (executor ? : context.mainExecutor()).execute {
393
425
onResult(
394
426
DeferredIssueResult .DocumentFailed (
@@ -479,8 +511,16 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
479
511
* @return [EudiWallet]
480
512
*/
481
513
fun setTrustedReaderCertificates (trustedReaderCertificates : List <X509Certificate >) = apply {
482
- deviceResponseGenerator.setReaderTrustStore(ReaderTrustStore .getDefault(trustedReaderCertificates))
483
- openId4VpCBORResponseGenerator.setReaderTrustStore(ReaderTrustStore .getDefault(trustedReaderCertificates))
514
+ deviceResponseGenerator.setReaderTrustStore(
515
+ ReaderTrustStore .getDefault(
516
+ trustedReaderCertificates
517
+ )
518
+ )
519
+ openId4VpCBORResponseGenerator.setReaderTrustStore(
520
+ ReaderTrustStore .getDefault(
521
+ trustedReaderCertificates
522
+ )
523
+ )
484
524
}
485
525
486
526
/* *
@@ -635,9 +675,10 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
635
675
// create response
636
676
val responseResult = when (transferMode) {
637
677
TransferMode .OPENID4VP ->
638
- openId4vpManager?.responseGenerator?.createResponse(disclosedDocuments) ? : ResponseResult .Failure (
639
- Throwable (" Openid4vpManager has not been initialized properly" )
640
- )
678
+ openId4vpManager?.responseGenerator?.createResponse(disclosedDocuments)
679
+ ? : ResponseResult .Failure (
680
+ Throwable (" Openid4vpManager has not been initialized properly" )
681
+ )
641
682
642
683
TransferMode .ISO_18013_5 , TransferMode .REST_API ->
643
684
transferManager.responseGenerator.createResponse(disclosedDocuments)
@@ -701,14 +742,22 @@ object EudiWallet : KeyGenerator by KeyGeneratorImpl {
701
742
private val transferManagerDocumentsResolver: DocumentsResolver
702
743
get() = DocumentsResolver { req ->
703
744
704
- // When()
705
- // get sdJwt docs
706
- // SdJwt filter
745
+ DocumentManagerSdJwt
746
+ .getAllDocuments()
747
+ .filter { doc -> doc.vct == req.docType }
748
+ .map { doc ->
749
+ RequestDocument (
750
+ documentId = doc.id,
751
+ docType = doc.vct,
752
+ docName = doc.docName,
753
+ userAuthentication = doc.requiresUserAuth,
754
+ docRequest = req
755
+ )
756
+ }.takeIf { it.isNotEmpty() }?.let { return @DocumentsResolver it }
707
757
708
- // Mdoc filter
709
- documentManager.getDocuments(Document .State .ISSUED )
758
+ return @DocumentsResolver documentManager.getDocuments(Document .State .ISSUED )
710
759
.filterIsInstance<IssuedDocument >()
711
- .filter { doc -> doc.docType == req.docType }
760
+ // .filter { doc -> doc.docType == req.docType }
712
761
.map { doc ->
713
762
RequestDocument (
714
763
documentId = doc.id,
0 commit comments